SlideShare una empresa de Scribd logo
1 de 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/

Más contenido relacionado

Destacado

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
 

Destacado (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
 

Similar a 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
 

Similar a 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 ...
 

Último

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 

Último (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

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/