SlideShare une entreprise Scribd logo
1  sur  22
PHPBelgium event 18-02-2009




   MVC = Make Venerated Code?


                                     Patrick Allaert


   PHPBelgium – Belgian PHP community
                    http://www.phpbelgium.be/
About Me
Started developping using PHP 3
Ten years of FOSS evangelism
Contribute to different FOSS:
   Tabellio (Open Source Collaboration for assemblies)
   Xoo°f (eXtensible Open Object Oriented Framework)
   KDESvn (Subversion frontend for KDE)
Lead developer:
   APM (Alternative PHP Monitor)
Working @ AUSY
Blog: http://patrickallaert.blogspot.com/


             PHPBelgium – Belgian PHP community
                                       http://www.phpbelgium.be/
Model-View-Controller (1)
“… is an architectural pattern used in software
 engineering. Successful use of the pattern
 isolates business logic from user interface
 considerations, resulting in an application
 where it is easier to modify either the visual
 appearance of the application or the underlying
 business rules without affecting the other.”
                                          Wikipedia


         PHPBelgium – Belgian PHP community
                          http://www.phpbelgium.be/
Model-View-Controller (2)


                                           Model
                                                          DB


Requests       Controller


                                                         (X)HTML
                                           View            XML




            PHPBelgium – Belgian PHP community
                             http://www.phpbelgium.be/
Design of some PHP applications




    PHPBelgium – Belgian PHP community
                     http://www.phpbelgium.be/
Managing this is sometimes...




           very difficult...
   PHPBelgium – Belgian PHP community
                    http://www.phpbelgium.be/
Demo application




/index.php                 /team.php?id=<TeamID>

PHPBelgium – Belgian PHP community
                 http://www.phpbelgium.be/
Spaghetti code




PHPBelgium – Belgian PHP community
                 http://www.phpbelgium.be/
Taking the Business Logic apart (1)




      PHPBelgium – Belgian PHP community
                       http://www.phpbelgium.be/
Taking the Business Logic apart (2)




      PHPBelgium – Belgian PHP community
                       http://www.phpbelgium.be/
Taking the Business Logic apart (3)




      PHPBelgium – Belgian PHP community
                       http://www.phpbelgium.be/
Evaluating the situation
Model is reusable         Views tightly linked to
Changes to the              the model
 business logic does      Views impacted if the
 not require inspecting     API of the model
 all files                  change
                          Calls to the model may
                            be difficult to find:
                            spread everywhere in
                            views

        PHPBelgium – Belgian PHP community
                          http://www.phpbelgium.be/
On the path to MVC (1)




PHPBelgium – Belgian PHP community
                 http://www.phpbelgium.be/
On the path to MVC (2)
Directory views to be added in the include_path
View parameters are passed using global
  variables
  Hint: $variableName may also be written:
  $GLOBALS['variableName']
  The latest form may be used to differentiate
  variables defined by the controller file from the
  local view variables
“htdocs” could be renamed “controllers”

         PHPBelgium – Belgian PHP community
                           http://www.phpbelgium.be/
Howto: Clean URL
Clean URL: Transforming
   http://example.com/index.php?type=article&id=25&date=20020322into:
   http://example.com/article/200203226
Enables better search engine indexing
URIs are not supposed to change (Cool URIs don't change)
Doesn't expose the server-side language
Most MVC Frameworks provide clean URL mechanism, how to
  setup one with our structure?




             PHPBelgium – Belgian PHP community
                                      http://www.phpbelgium.be/
Clean URL: method #1
Using Apache's mod_rewrite:
 RewriteEngine On
 RewriteRule ^/team/([0-9]*)$ /team.php?id=$1 [L]

Ability to transform URLs on the fly and mapping
 part of the URL directly to a $_GET variable




         PHPBelgium – Belgian PHP community
                             http://www.phpbelgium.be/
Clean URL: method #2
Dropping the “.php” extension and forcing the
 mime-type/handler used in the Apache
 configuration
<FilesMatch "^(index|team)$">
      ForceType application/x-httpd-php
  </FilesMatch>
 or:
 <FilesMatch "^(index|team)$">
     SetHandler application/x-httpd-php
 </FilesMatch>


        PHPBelgium – Belgian PHP community
                         http://www.phpbelgium.be/
Performance impact (index page)

 Concurrency           1                           15
 “spaghetti”         1483.15                     2798.23
 Model-View          1353.17                     2388.61
 MVC                 1339.72                     2364.66
 Clean URL #1        1320.61                     2303.99
 Clean URL #2        1412.43                     2468.83
 Zend Framework       164.11                     280.22
                               In requests/second, higher = better




         PHPBelgium – Belgian PHP community
                               http://www.phpbelgium.be/
Performance impact (team page)

 Concurrency           1                           15
 “spaghetti”         1372.66                     2428.79
 Model-View          1243.78                     2142.79
 MVC                 1235.48                     2364.66
 Clean URL #1        1232.39                     2090.51
 Clean URL #2        1192.78                     2040.44
 Zend Framework      158.77                      264.65
                               In requests/second, higher = better




         PHPBelgium – Belgian PHP community
                               http://www.phpbelgium.be/
Questions ?




PHPBelgium – Belgian PHP community
                 http://www.phpbelgium.be/
Thanks :-)




These slides will be available through:
        http://patrickallaert.blogspot.com/




   PHPBelgium – Belgian PHP community
                          http://www.phpbelgium.be/
License
This presentation material is published under the Creative Commons Attribution-Share Alike 3.0 Unported license.
You are free:
to Share — to copy, distribute and transmit the work
to Remix — to adapt the work
Under the following conditions:
Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way that
  suggests that they endorse you or your use of the work).
Share Alike — If you alter, transform, or build upon this work, you may distribute the resulting work only under the
  same, similar or a compatible license.
With the understanding that:
Waiver — Any of the above conditions can be waived if you get permission from the copyright holder.
Other Rights — In no way are any of the following rights affected by the license:
  Your fair dealing or fair use rights;
  The author's moral rights;
  Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy
    rights.
Notice — For any reuse or distribution, you must make clear to others the license terms of this work.




                         PHPBelgium – Belgian PHP community
                                                             http://www.phpbelgium.be/

Contenu connexe

En vedette

La métrique, ce n'est pas que pour le devops
La métrique, ce n'est pas que pour le devopsLa métrique, ce n'est pas que pour le devops
La métrique, ce n'est pas que pour le devopsPatrick Allaert
 
Maitriser les structures de données PHP 102 - Forum Paris 2012
Maitriser les structures de données PHP 102 - Forum Paris 2012Maitriser les structures de données PHP 102 - Forum Paris 2012
Maitriser les structures de données PHP 102 - Forum Paris 2012Patrick Allaert
 
Advanced debugging techniques (PHP)
Advanced debugging techniques (PHP)Advanced debugging techniques (PHP)
Advanced debugging techniques (PHP)Patrick Allaert
 
Mastering PHP Data Structure 102 - phpDay 2012 Verona
Mastering PHP Data Structure 102 - phpDay 2012 VeronaMastering PHP Data Structure 102 - phpDay 2012 Verona
Mastering PHP Data Structure 102 - phpDay 2012 VeronaPatrick Allaert
 
Create your own PHP extension, step by step - phpDay 2012 Verona
Create your own PHP extension, step by step - phpDay 2012 VeronaCreate your own PHP extension, step by step - phpDay 2012 Verona
Create your own PHP extension, step by step - phpDay 2012 VeronaPatrick Allaert
 
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, ItalyPHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, ItalyPatrick Allaert
 

En vedette (6)

La métrique, ce n'est pas que pour le devops
La métrique, ce n'est pas que pour le devopsLa métrique, ce n'est pas que pour le devops
La métrique, ce n'est pas que pour le devops
 
Maitriser les structures de données PHP 102 - Forum Paris 2012
Maitriser les structures de données PHP 102 - Forum Paris 2012Maitriser les structures de données PHP 102 - Forum Paris 2012
Maitriser les structures de données PHP 102 - Forum Paris 2012
 
Advanced debugging techniques (PHP)
Advanced debugging techniques (PHP)Advanced debugging techniques (PHP)
Advanced debugging techniques (PHP)
 
Mastering PHP Data Structure 102 - phpDay 2012 Verona
Mastering PHP Data Structure 102 - phpDay 2012 VeronaMastering PHP Data Structure 102 - phpDay 2012 Verona
Mastering PHP Data Structure 102 - phpDay 2012 Verona
 
Create your own PHP extension, step by step - phpDay 2012 Verona
Create your own PHP extension, step by step - phpDay 2012 VeronaCreate your own PHP extension, step by step - phpDay 2012 Verona
Create your own PHP extension, step by step - phpDay 2012 Verona
 
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, ItalyPHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
 

Similaire à MVC = Make Venerated Code?

Rapid Development With CakePHP
Rapid Development With CakePHPRapid Development With CakePHP
Rapid Development With CakePHPEdureka!
 
Vue micro frontend implementation patterns
Vue micro frontend implementation patternsVue micro frontend implementation patterns
Vue micro frontend implementation patternsAlbert Brand
 
Edp bootstrapping a-software_company
Edp bootstrapping a-software_companyEdp bootstrapping a-software_company
Edp bootstrapping a-software_companyGanesh Kulkarni
 
CodeIgniter Basics - Tutorial for Beginners
CodeIgniter Basics - Tutorial for Beginners CodeIgniter Basics - Tutorial for Beginners
CodeIgniter Basics - Tutorial for Beginners Isuru Thilakarathne
 
PHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniterPHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniterKHALID C
 
Php through the eyes of a hoster: PHPNW10
Php through the eyes of a hoster: PHPNW10Php through the eyes of a hoster: PHPNW10
Php through the eyes of a hoster: PHPNW10Combell NV
 
Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - ...
Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - ...Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - ...
Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - ...Gaetano Giunta
 
Php Frameworks
Php FrameworksPhp Frameworks
Php FrameworksRyan Davis
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfonyFrancois Zaninotto
 
Php Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerPhp Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerJackson F. de A. Mafra
 
A Good PHP Framework For Beginners Like Me!
A Good PHP Framework For Beginners Like Me!A Good PHP Framework For Beginners Like Me!
A Good PHP Framework For Beginners Like Me!Muhammad Ghazali
 
Building Web Applications with Zend Framework
Building Web Applications with Zend FrameworkBuilding Web Applications with Zend Framework
Building Web Applications with Zend FrameworkPhil Brown
 
Workshop: Refactoring Legacy PHP: The Complete Guide
Workshop: Refactoring Legacy PHP: The Complete Guide Workshop: Refactoring Legacy PHP: The Complete Guide
Workshop: Refactoring Legacy PHP: The Complete Guide Junade Ali
 
Why CakePHP Is Superior to Other Web Frameworks! Examine Its Pros & Cons For ...
Why CakePHP Is Superior to Other Web Frameworks! Examine Its Pros & Cons For ...Why CakePHP Is Superior to Other Web Frameworks! Examine Its Pros & Cons For ...
Why CakePHP Is Superior to Other Web Frameworks! Examine Its Pros & Cons For ...JPLoft Solutions
 

Similaire à MVC = Make Venerated Code? (20)

Rapid Development With CakePHP
Rapid Development With CakePHPRapid Development With CakePHP
Rapid Development With CakePHP
 
Cakephp manual-11
Cakephp manual-11Cakephp manual-11
Cakephp manual-11
 
Vue micro frontend implementation patterns
Vue micro frontend implementation patternsVue micro frontend implementation patterns
Vue micro frontend implementation patterns
 
Edp bootstrapping a-software_company
Edp bootstrapping a-software_companyEdp bootstrapping a-software_company
Edp bootstrapping a-software_company
 
CodeIgniter Basics - Tutorial for Beginners
CodeIgniter Basics - Tutorial for Beginners CodeIgniter Basics - Tutorial for Beginners
CodeIgniter Basics - Tutorial for Beginners
 
PHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniterPHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniter
 
Php through the eyes of a hoster: PHPNW10
Php through the eyes of a hoster: PHPNW10Php through the eyes of a hoster: PHPNW10
Php through the eyes of a hoster: PHPNW10
 
Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - ...
Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - ...Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - ...
Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - ...
 
Magento
MagentoMagento
Magento
 
Php Frameworks
Php FrameworksPhp Frameworks
Php Frameworks
 
Php myadmin
Php myadminPhp myadmin
Php myadmin
 
Php Framework
Php FrameworkPhp Framework
Php Framework
 
Php framework
Php frameworkPhp framework
Php framework
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
 
Php Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerPhp Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant Killer
 
A Good PHP Framework For Beginners Like Me!
A Good PHP Framework For Beginners Like Me!A Good PHP Framework For Beginners Like Me!
A Good PHP Framework For Beginners Like Me!
 
Introduction To CodeIgniter
Introduction To CodeIgniterIntroduction To CodeIgniter
Introduction To CodeIgniter
 
Building Web Applications with Zend Framework
Building Web Applications with Zend FrameworkBuilding Web Applications with Zend Framework
Building Web Applications with Zend Framework
 
Workshop: Refactoring Legacy PHP: The Complete Guide
Workshop: Refactoring Legacy PHP: The Complete Guide Workshop: Refactoring Legacy PHP: The Complete Guide
Workshop: Refactoring Legacy PHP: The Complete Guide
 
Why CakePHP Is Superior to Other Web Frameworks! Examine Its Pros & Cons For ...
Why CakePHP Is Superior to Other Web Frameworks! Examine Its Pros & Cons For ...Why CakePHP Is Superior to Other Web Frameworks! Examine Its Pros & Cons For ...
Why CakePHP Is Superior to Other Web Frameworks! Examine Its Pros & Cons For ...
 

Dernier

CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 

Dernier (20)

CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

MVC = Make Venerated Code?

  • 1. PHPBelgium event 18-02-2009 MVC = Make Venerated Code? Patrick Allaert PHPBelgium – Belgian PHP community http://www.phpbelgium.be/
  • 2. About Me Started developping using PHP 3 Ten years of FOSS evangelism Contribute to different FOSS: Tabellio (Open Source Collaboration for assemblies) Xoo°f (eXtensible Open Object Oriented Framework) KDESvn (Subversion frontend for KDE) Lead developer: APM (Alternative PHP Monitor) Working @ AUSY Blog: http://patrickallaert.blogspot.com/ PHPBelgium – Belgian PHP community http://www.phpbelgium.be/
  • 3. Model-View-Controller (1) “… is an architectural pattern used in software engineering. Successful use of the pattern isolates business logic from user interface considerations, resulting in an application where it is easier to modify either the visual appearance of the application or the underlying business rules without affecting the other.” Wikipedia PHPBelgium – Belgian PHP community http://www.phpbelgium.be/
  • 4. Model-View-Controller (2) Model DB Requests Controller (X)HTML View XML PHPBelgium – Belgian PHP community http://www.phpbelgium.be/
  • 5. Design of some PHP applications PHPBelgium – Belgian PHP community http://www.phpbelgium.be/
  • 6. Managing this is sometimes... very difficult... PHPBelgium – Belgian PHP community http://www.phpbelgium.be/
  • 7. Demo application /index.php /team.php?id=<TeamID> PHPBelgium – Belgian PHP community http://www.phpbelgium.be/
  • 8. Spaghetti code PHPBelgium – Belgian PHP community http://www.phpbelgium.be/
  • 9. Taking the Business Logic apart (1) PHPBelgium – Belgian PHP community http://www.phpbelgium.be/
  • 10. Taking the Business Logic apart (2) PHPBelgium – Belgian PHP community http://www.phpbelgium.be/
  • 11. Taking the Business Logic apart (3) PHPBelgium – Belgian PHP community http://www.phpbelgium.be/
  • 12. Evaluating the situation Model is reusable Views tightly linked to Changes to the the model business logic does Views impacted if the not require inspecting API of the model all files change Calls to the model may be difficult to find: spread everywhere in views PHPBelgium – Belgian PHP community http://www.phpbelgium.be/
  • 13. On the path to MVC (1) PHPBelgium – Belgian PHP community http://www.phpbelgium.be/
  • 14. On the path to MVC (2) Directory views to be added in the include_path View parameters are passed using global variables Hint: $variableName may also be written: $GLOBALS['variableName'] The latest form may be used to differentiate variables defined by the controller file from the local view variables “htdocs” could be renamed “controllers” PHPBelgium – Belgian PHP community http://www.phpbelgium.be/
  • 15. Howto: Clean URL Clean URL: Transforming http://example.com/index.php?type=article&id=25&date=20020322into: http://example.com/article/200203226 Enables better search engine indexing URIs are not supposed to change (Cool URIs don't change) Doesn't expose the server-side language Most MVC Frameworks provide clean URL mechanism, how to setup one with our structure? PHPBelgium – Belgian PHP community http://www.phpbelgium.be/
  • 16. Clean URL: method #1 Using Apache's mod_rewrite: RewriteEngine On RewriteRule ^/team/([0-9]*)$ /team.php?id=$1 [L] Ability to transform URLs on the fly and mapping part of the URL directly to a $_GET variable PHPBelgium – Belgian PHP community http://www.phpbelgium.be/
  • 17. Clean URL: method #2 Dropping the “.php” extension and forcing the mime-type/handler used in the Apache configuration <FilesMatch "^(index|team)$"> ForceType application/x-httpd-php </FilesMatch> or: <FilesMatch "^(index|team)$"> SetHandler application/x-httpd-php </FilesMatch> PHPBelgium – Belgian PHP community http://www.phpbelgium.be/
  • 18. Performance impact (index page) Concurrency 1 15 “spaghetti” 1483.15 2798.23 Model-View 1353.17 2388.61 MVC 1339.72 2364.66 Clean URL #1 1320.61 2303.99 Clean URL #2 1412.43 2468.83 Zend Framework 164.11 280.22 In requests/second, higher = better PHPBelgium – Belgian PHP community http://www.phpbelgium.be/
  • 19. Performance impact (team page) Concurrency 1 15 “spaghetti” 1372.66 2428.79 Model-View 1243.78 2142.79 MVC 1235.48 2364.66 Clean URL #1 1232.39 2090.51 Clean URL #2 1192.78 2040.44 Zend Framework 158.77 264.65 In requests/second, higher = better PHPBelgium – Belgian PHP community http://www.phpbelgium.be/
  • 20. Questions ? PHPBelgium – Belgian PHP community http://www.phpbelgium.be/
  • 21. Thanks :-) These slides will be available through: http://patrickallaert.blogspot.com/ PHPBelgium – Belgian PHP community http://www.phpbelgium.be/
  • 22. License This presentation material is published under the Creative Commons Attribution-Share Alike 3.0 Unported license. You are free: to Share — to copy, distribute and transmit the work to Remix — to adapt the work Under the following conditions: Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). Share Alike — If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or a compatible license. With the understanding that: Waiver — Any of the above conditions can be waived if you get permission from the copyright holder. Other Rights — In no way are any of the following rights affected by the license: Your fair dealing or fair use rights; The author's moral rights; Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights. Notice — For any reuse or distribution, you must make clear to others the license terms of this work. PHPBelgium – Belgian PHP community http://www.phpbelgium.be/