How to build customizable multitenant web applications - IPC11 Spring Edition
Upcoming SlideShare
Loading in...5
×
 

How to build customizable multitenant web applications - IPC11 Spring Edition

on

  • 9,700 views

 

Statistics

Views

Total Views
9,700
Views on SlideShare
8,924
Embed Views
776

Actions

Likes
6
Downloads
222
Comments
0

6 Embeds 776

http://lanyrd.com 739
http://servidor1.i2e.es 31
http://www.php-talks.com 3
https://lanyrd.com 1
http://translate.googleusercontent.com 1
http://webcache.googleusercontent.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

How to build customizable multitenant web applications - IPC11 Spring Edition How to build customizable multitenant web applications - IPC11 Spring Edition Presentation Transcript

  • How to build customizablemultitenant web applications
  • Multitenant web applications About me  Stephan Hochdörfer, bitExpert AG  Department Manager Research Labs  enjoying PHP since 1999  S.Hochdoerfer@bitExpert.de  @shochdoerfer
  • Multitenant web applications Single Tenancy View slide
  • Multitenant web applications Developer vs. Businessman View slide
  • Multitenant web applications Single Tenancy – more customers
  • Multitenant web applications Single Tenancy – even more customers
  • Multitenant web applications Where will this lead to?
  • Multitenant web applications Maintenance nightmare!
  • Multitenant web applications Single Tenancy Tenant 1 Application Database Hardware
  • Multitenant web applications Single Tenancy Tenant 1 Tenant 2 Tenant 3 Application Application Application Database Database Database Hardware Hardware Hardware
  • Multitenant web applications Multi Tenancy Tenant 1 Tenant 2 Tenant 3 Application Database Hardware
  • Multitenant web applications What should be customizable?
  • Multitenant web applications What should be customizable? Tenant 1 Tenant 2 Tenant 3 Application Database Hardware
  • Multitenant web applications What should be customizable? Tenant 1 Tenant 2 Tenant 3 Application Database Hardware
  • Multitenant web applications How to skin an application?
  • Multitenant web applications How to skin an application? Remember: It`s a web application!
  • Multitenant web applications How to skin an application? HTML
  • Multitenant web applications How to skin an application? HTML + CSS
  • Multitenant web applications
  • Multitenant web applications
  • Multitenant web applications
  • Multitenant web applications How to customize? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1- strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>My App</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="css/styles/myapp.css" /> </head> <body> </body> </html>
  • Multitenant web applications How to customize? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>My App</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="css/styles/<?php echo $tenant ?>.css" /> </head> <body> </body> </html>
  • Multitenant web applications How to customize? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1- strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>My App</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="css/styles/myapp.css" /> <link rel="stylesheet" type="text/css" href="css/styles/<?php echo $tenant ?>.css" /> </head> <body> </body> </html>
  • Multitenant web applications Feature driven CSS Wait, there`s more...
  • Multitenant web applications Feature driven CSS display: none
  • Multitenant web applications This is not an security advice!
  • Multitenant web applications Next level...
  • Multitenant web applications Menubar generation <?php if($user->hasEnabled(Module::ORDERMANAGEMENT)) { if($user->canAccess(OrderManagement::LIST_ORDERS)) { $this->renderLink(OrderManagement::LIST_ORDERS); } if($user->canAccess(OrderManagement::ADD_ORDER)) { $this->renderLink(OrderManagement::ADD_ORDER); } }
  • Multitenant web applications Menubar generation <?php if($tenant->hasModule(Module::ORDERMANAGEMENT) { if($user->hasEnabled(Module::ORDERMANAGEMENT)) { if($user->canAccess(OrderManagement::LIST_ORDERS)) { $this->renderLink(OrderManagement::LIST_ORDERS); } if($user->canAccess(OrderManagement::ADD_ORDER)) { $this->renderLink(OrderManagement::ADD_ORDER); } } }
  • Multitenant web applications Menubar generation Modularize!
  • Multitenant web applications Menubar generation Module 1 Module 2 Module 3 register at start up Application core
  • Multitenant web applications Menubar generation Module 1 Module 2 Module 3 register at start up Application core
  • Multitenant web applications Menubar generation Module 1 Module 2 Module 3 register at start up Application core
  • Multitenant web applications Optimize workflows
  • Multitenant web applications Optimize workflows <?php if(CC == $paymentType) { // handle credit card payment } else if(COD == $paymentType) { // handle cash on delivery payment }
  • Multitenant web applications Optimize workflows <?php if(CC == $paymentType) { // handle credit card payment for some tenants! if(in_array($tenant->getName(), array(tenant1, tenant2)) { // insert logic here... } } else if(COD == $paymentType) { // handle cash on delivery payment for some tenants! }
  • Multitenant web applications Optimize workflows Decouple functionality!
  • Multitenant web applications Optimize workflows <?php $paymentType = CC; // set via request $payment = PaymentFactory::create($paymentType); $payment->execute($order);
  • Multitenant web applications Optimize workflows <?php $paymentType = CC; // set via request $payment = PaymentFactory::create($paymentType, $tenant); $payment->execute($order);
  • Multitenant web applications Optimize workflows How to add custom logic?
  • Multitenant web applications Custom logic - Subclassing? Abstract Payment CC Payment CCPayment CCPayment Tenant 1 Tenant 2
  • Multitenant web applications Custom logic Any alternatives?
  • Multitenant web applications Custom logic Let`s add hooks...
  • Multitenant web applications Custom logic - Hooks <?php $paymentType = CC; // set via request $payment = PaymentFactory::create($paymentType, $tenant); $payment->execute($order); if($this->paymentPostProcessor instanceof IPaymentPostProcessor) { $this->paymentPostProcessor->run($payment, $tenant, $order); }
  • Multitenant web applications Custom logic How to set the dependencies?
  • Multitenant web applications Custom logic Dependency Injection!
  • Multitenant web applications Custom logic – Dependency Injection <?xml version="1.0" encoding="UTF-8" ?> <beans xmlns="http://www.bitexpert.de/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bitexpert.de/schema/ http://www.bitexpert.de/schema/bitFramework- beans.xsd"> <bean id="Service.Order" class="MyAppServiceOrder.php"> </bean> <bean id="Tenant1.Order" class="MyAppServiceOrder.php"> <property name="paymentPostProcessor" ref="Tentant1.Payment.SendOrderMail" /> </bean> </beans>
  • Multitenant web applications Custom logic – Dependency Injection <?xml version="1.0" encoding="UTF-8" ?> <beans xmlns="http://www.bitexpert.de/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bitexpert.de/schema/ http://www.bitexpert.de/schema/bitFramework- beans.xsd"> <bean id="Tenant2.Order" class="MyAppServiceOrder.php"> <property name="paymentPostProcessor" ref="Tentant1.Payment.PushToERP" /> </bean> </beans>
  • Multitenant web applications Custom logic Any further improvements?
  • Multitenant web applications Custom logic <?php $paymentType = CC; // set via request $payment = PaymentFactory::create($paymentType, $tenant); $payment->execute($order); if($this->paymentPostProcessor instanceof IPaymentPostProcessor) { $this->paymentPostProcessor->run($payment, $tenant, $order); }
  • Multitenant web applications Custom logic <?php $paymentType = CC; // set via request $payment = PaymentFactory::create($paymentType, $tenant); $payment->execute($order); if($this->paymentPostProcessor instanceof IPaymentPostProcessor) { $this->paymentPostProcessor->run($payment, $tenant, $order); }
  • Multitenant web applications Custom logic Aspect-oriented programming
  • Multitenant web applications Custom logic – Aspects for the masses! /** * @aspect */ class CustomPaymentProcessingAspect { /** * @around MyAppServiceOrder->processPayment */ public function customFilter(JoinPointInterface $jP) { $result = $jP->getAdviceChain()->proceed($jP); // @TODO: implement post-processing logic return $result; } }
  • Multitenant web applications Custom logic - Result <?php $paymentType = CC; // set via request $payment = PaymentFactory::create($paymentType, $tenant); $payment->execute($order);
  • Multitenant web applications Next level...
  • Multitenant web applications Database – Where to store the data?
  • Multitenant web applications Database – Where to store the data? We need to store data for a tenant!
  • Multitenant web applications Database – Where to store the data? Database per Tenant?
  • Multitenant web applications Database – Where to store the data? Database per Tenant? Schema per Tenant?
  • Multitenant web applications Database – Where to store the data? Database per Tenant? Schema per Tenant? Tenant Id per Row?
  • Multitenant web applications Database – How to access the data? vs. ORM dynamic statements
  • Multitenant web applications Generalize you should!
  • Multitenant web applications No single solution!
  • Multitenant web applications Softwaresystemfamily
  • Multitenant web applications A factory for mass production!
  • Multitenant web applications Multi Tenancy – Single Instance Tenant 1 Tenant 2 Tenant 3 Application Database Hardware
  • Multitenant web applications Multi Tenancy – Multi Instance Tenant 1 Tenant 2 Tenant 3 Application Database Hardware
  • Multitenant web applications Multi Tenancy – Multi Instance Generative Programming
  • Multitenant web applications Generative Programming Generator Generator
  • Multitenant web applications Generative Programming Configuration Configuration (DSL) (DSL) Generator Generator
  • Multitenant web applications Generative Programming Configuration Configuration (DSL) (DSL) Implementation- Implementation- components Generator Generator components
  • Multitenant web applications Generative Programming Configuration Configuration (DSL) (DSL) 1..n Implementation- Implementation- components Generator Generator Product components Product
  • Multitenant web applications Generative Programming Configuration Configuration (DSL) (DSL) Implementation- Implementation- components Generator Generator Tenant 11 components Tenant
  • Multitenant web applications Generative Programming Configuration Configuration (DSL) (DSL) Tenant 22 Tenant Implementation- Implementation- components Generator Generator Tenant 11 components Tenant
  • Multitenant web applications Generative Programming Tenant 33 Tenant Configuration Configuration (DSL) (DSL) Tenant 22 Tenant Implementation- Implementation- components Generator Generator Tenant 11 components Tenant
  • Multitenant web applications Generative Programming - Goal Create an optimized application!
  • Multitenant web applications Generative Programming - Goal Create an optimized application for one tenant!
  • Multitenant web applications Generative Programming – Bonus points
  • Multitenant web applications Generative Programming – Bonus points Reduce application complexity
  • Multitenant web applications Generative Programming – Bonus points <?php $paymentType = CC; // set via request $payment = PaymentFactory::create($paymentType, $tenant); $payment->execute($order); <!{PostProcessor}!>
  • Multitenant web applications Generative Programming – Bonus points public class PostProcessorFrame extends SimpleFrameController { public void execute(Frame frame, FeatureConfig config) { if(config.hasFeature("order_send_mail")) { frame.setSlot("PostProcessor", "..."); } if(config.hasFeature("order_push_to_erp")) { frame.setSlot("PostProcessor", "..."); } } }
  • Multitenant web applications Generative Programming – Bonus points Reduce maintenance support
  • Multitenant web applications Generative Programming – Bonus points Implementation Feature component
  • Multitenant web applications Generative Programming – Bonus points Feature Tenant
  • Multitenant web applications Generative Programming – Bonus points Tenant Feature Implementation component
  • Multitenant web applications Generative Programming – The book
  • http://joind.in/3517
  • Flickr Creditshttp://www.flickr.com/photos/andresrueda/3452940751/http://www.flickr.com/photos/andresrueda/3455410635/