Enterprise PHP Development

                 Ivo Jansch - ivo@ibuildings.com


                        php|works 2008

Ent...
What’s an Enterprise?
            “Any of several ships by that name
          in the Star Trek universe” – Wikipedia




...
What’s an Enterprise?
            “Any of several ships by that name
          in the Star Trek universe” – Wikipedia




...
What’s an Enterprise?
             “Any of several ships by that name
           in the Star Trek universe” – Wikipedia


...
PHP usage is changing




Enterprise PHP
PHP usage is changing
•    1998
      •    Personal stuff




    Enterprise PHP
PHP usage is changing
•    1998
      •    Personal stuff

•    2003
      •    Simple websites
      •    Content managem...
PHP usage is changing
•    1998
      •    Personal stuff

•    2003
      •    Simple websites
      •    Content managem...
PHP’s Quest so far

                             Enterprise



                                     SME


                ...
Is PHP ‘enterprise ready’?




Enterprise PHP
Is PHP ‘enterprise ready’?




 Big                           Small
 Enterprise friendly           Lightweight

 ente...
A word from my girlfriend


            It's not the   SIZE of the tool...

                 It's how you USE it.




Ente...
Traditional PHP metaphor

                 PHP is like LEGO bricks




Enterprise PHP
Improved metaphor
                       PHP is no longer a toy
                 Let’s use the metaphor of actual bricks

...
About Bricks


•    Extreme Simplicity
•    Easy to learn
•    Versatile
•    Inexpensive




    Enterprise PHP
Enterprise Development
                 In 10 steps




Enterprise PHP
Step 1 – The Team
     “I have read about your plans to build a new
         skyscraper and I am applying for a job.

I ha...
Step 1 – The Team
• Be a Software Engineer
• Train your skills
• Study OO principles
• Consider Zend Certification



 Ente...
Step 2 - Requirements
• What does the customer want?
• What will visitors want?
• What does the customer really need?




...
Step 2 - Requirements
Functional Design
  •   Requirements Definition
  •   Interaction Design / Wireframes
  •   Flow Diag...
Step 3 - Architecture




Enterprise PHP
Step 3 - Architecture
Don’t just start stacking bricks




  Enterprise PHP
Step 3 - Architecture
Don’t just start stacking bricks




                             Create an architecture first

  Ent...
Step 3 - Architecture
Technical Design
  •   Modeling
      • Class Diagrams
      • ER Diagrams (data model)
      • Coll...
Step 3 - Architecture
High Level Architectures:

   •   MVC (Model, View, Controller)
   •   SOA (Service Oriented Archite...
Step 4 - Tools




Enterprise PHP
Step 4 - Tools
You don’t need tools…




  Enterprise PHP
Step 4 - Tools
You don’t need tools…



                        But they make you productive




  Enterprise PHP
Step 4 - Tools
Development:
   •   Eclipse PDT
   •   Zend Studio
   •   PhpEd
   •   Vim
   •   Komodo

IDE’s versus Edit...
Step 4 - Tools
Development:
   •   Eclipse PDT
   •   Zend Studio
   •   PhpEd
   •   Vim
   •   Komodo

IDE’s versus Edit...
Step 4 - Tools




Enterprise PHP
Step 4 - Tools
Source Control
  •   CVS / SVN / MS VSS
  •   Bitkeeper / GIT




 Enterprise PHP
Step 4 - Tools
Source Control
  •   CVS / SVN / MS VSS
  •   Bitkeeper / GIT




Documentation
  •   phpDocumentor
       ...
Step 5 - Foundation




Enterprise PHP
Step 5 - Foundation
Start stacking bricks?
   •   How many bricks does it take?
   •   What about stability?




  Enterpr...
Step 5 - Foundation
Start stacking bricks?
   •   How many bricks does it take?
   •   What about stability?




         ...
Step 5 - Foundation
Use a framework
  •   Provides guidelines (frame)
  •   Off the shelf components

Examples
  •   Zend ...
Step 5 - Foundation
The “Not Invented Here” Syndrome:


  •   “The existing frameworks are no good.
      
 
 I can do thi...
Step 6 - Design Patterns

                     Requirement 1056.4:

           We need to be able to look outside,
       ...
Step 6 - Design Patterns




Enterprise PHP
Step 6 - Design Patterns
• A ‘window’ is a concept
  •   Best practice way of solving a particular problem




 Enterprise...
Step 6 - Design Patterns
• A ‘window’ is a concept
  •   Best practice way of solving a particular problem

• In IT, we ca...
Step 6 - Design Patterns
• A ‘window’ is a concept
  •   Best practice way of solving a particular problem

• In IT, we ca...
Step 6 - Design Patterns
• A ‘window’ is a concept
  •   Best practice way of solving a particular problem

• In IT, we ca...
Step 7 - Testing




  Is your software tested after it has gone live?
Enterprise PHP
Step 7 - Testing
Various types of testing:
   •   Developer testing
   •   Functional testing
   •   Environment testing
 ...
Step 7 - Testing
                 A common scenario…




Enterprise PHP
Step 7 - Testing
                   The user complains…




                 MWOEHA!
                  BUG!




Enterprise...
Step 7 - Testing
             Developer attacks the problem…




                 fix_bug();




Enterprise PHP
Step 7 - Testing
                   Problem Solved!




Enterprise PHP
Step 7 - Testing




Enterprise PHP
Step 7 - Testing
• Solution: Unit Tests
   •    Automated testing after each change
   •    Prevents regressions




  Ent...
Step 7 - Testing
• Solution: Unit Tests
   •    Automated testing after each change
   •    Prevents regressions

• Testin...
Step 7 - Testing
• Solution: Unit Tests
   •    Automated testing after each change
   •    Prevents regressions

• Testin...
Step 7 - Testing
• Test Driven Development
  1. Define functionality
  2. Create testcase
  3. Run test => test fails
  4. ...
Step 8 - Optimization

                 Users are reporting:


        quot;I work on the 197th floor. Every day I
       h...
Step 8 - Optimization
                  Solution: Elevator




Enterprise PHP
Step 8 - Optimization




Enterprise PHP
Step 8 - Optimization
In PHP, this ‘elevator’ is called an ‘accelerator’




  Enterprise PHP
Step 8 - Optimization
In PHP, this ‘elevator’ is called an ‘accelerator’

   •   This is how PHP works (pseudo-ish code):
...
Step 8 - Optimization
In PHP, this ‘elevator’ is called an ‘accelerator’

   •   This is how PHP works (pseudo-ish code):
...
Step 8 - Optimization
In PHP, this ‘elevator’ is called an ‘accelerator’

   •   This is how PHP works (pseudo-ish code):
...
Step 8 - Optimization

                    Users complain:


          “Every time I want coffee I have to go
            ...
Step 8 - Optimization




Enterprise PHP
Step 8 - Optimization
• Solution:
  •    Create small coffee corners on every floor so people don’t
       have to go to th...
Step 8 - Optimization
• Solution:
   •    Create small coffee corners on every floor so people don’t
        have to go to ...
Step 8 - Optimization
• Solution:
   •    Create small coffee corners on every floor so people don’t
        have to go to ...
Step 9 - Deployment
•    Lifecycle:
     •    Develop
     •    Test
     •    Deploy to staging environment
     •    Dep...
Step 9 - Deployment
                    System Architecture


                       PHP
                                 ...
Step 9 - Deployment




   … to a High Availability, Scalable Architecture
Enterprise PHP
Step 10 - Operations

Monitoring:


  •   Logfiles
  •   Monitor infrastructure (tools such as Nagios)
  •   Monitor applic...
Step 10 - Operations
Debugging

  •   Ideal:

      “I had error x when I selected y after I clicked z”

  •   Reality:

 ...
Step 10 - Operations

Solutions:
   •   A ‘root cause’
       analysis tool
   •   Logging
   •   Context Capture




  En...
Step 10 - Operations

Change management:


  •   Ticket system
  •   Stick to your deployment - use the DRP
  •   DON'T TO...
The Big Picture
                   (We’re almost done)




Enterprise PHP
The Big Picture




Enterprise PHP
The Big Picture
• No ‘cowboy coding’, but structured steps
  •   Higher quality
  •   Software will be easier to maintain ...
The Big Picture
• No ‘cowboy coding’, but structured steps
  •   Higher quality
  •   Software will be easier to maintain ...
The Big Picture
• No ‘cowboy coding’, but structured steps
  •   Higher quality
  •   Software will be easier to maintain ...
More things to think about

• Planning
• Coding
• Implementation
• Security


 Enterprise PHP
Shameless Plug
Book about this all:
   •   php|architect’s Guide to
       Enterprise PHP Development
   •   ISBN: 978-0-9...
Questions?
                    ivo@ibuildings.com
                 http://www.ibuildings.com
                    http://ww...
Upcoming SlideShare
Loading in...5
×

Enterprise PHP (php|works 2008)

11,518

Published on

Enterprise PHP presentation at the php|works conference in november 2008 in Atlanta.

Published in: Technology
2 Comments
36 Likes
Statistics
Notes
No Downloads
Views
Total Views
11,518
On Slideshare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
629
Comments
2
Likes
36
Embeds 0
No embeds

No notes for slide

Enterprise PHP (php|works 2008)

  1. 1. Enterprise PHP Development Ivo Jansch - ivo@ibuildings.com php|works 2008 Enterprise PHP
  2. 2. What’s an Enterprise? “Any of several ships by that name in the Star Trek universe” – Wikipedia Enterprise PHP
  3. 3. What’s an Enterprise? “Any of several ships by that name in the Star Trek universe” – Wikipedia Enterprise PHP
  4. 4. What’s an Enterprise? “Any of several ships by that name in the Star Trek universe” – Wikipedia “A business, company or comparable organization” Enterprise PHP
  5. 5. PHP usage is changing Enterprise PHP
  6. 6. PHP usage is changing • 1998 • Personal stuff Enterprise PHP
  7. 7. PHP usage is changing • 1998 • Personal stuff • 2003 • Simple websites • Content management • Blogs Enterprise PHP
  8. 8. PHP usage is changing • 1998 • Personal stuff • 2003 • Simple websites • Content management • Blogs • 2008 • Big websites • Banks • Insurance Companies Enterprise PHP
  9. 9. PHP’s Quest so far Enterprise SME SOHO Enterprise PHP
  10. 10. Is PHP ‘enterprise ready’? Enterprise PHP
  11. 11. Is PHP ‘enterprise ready’?  Big  Small  Enterprise friendly  Lightweight  enterpriCe  Inexpensive  CS required  Easy to learn Enterprise PHP
  12. 12. A word from my girlfriend It's not the SIZE of the tool... It's how you USE it. Enterprise PHP
  13. 13. Traditional PHP metaphor PHP is like LEGO bricks Enterprise PHP
  14. 14. Improved metaphor PHP is no longer a toy Let’s use the metaphor of actual bricks Enterprise PHP
  15. 15. About Bricks • Extreme Simplicity • Easy to learn • Versatile • Inexpensive Enterprise PHP
  16. 16. Enterprise Development In 10 steps Enterprise PHP
  17. 17. Step 1 – The Team “I have read about your plans to build a new skyscraper and I am applying for a job. I have a lot of experience with Bricks. I taught myself how to use them and have been maintaining our family shed for a few years now.” Enterprise PHP
  18. 18. Step 1 – The Team • Be a Software Engineer • Train your skills • Study OO principles • Consider Zend Certification Enterprise PHP
  19. 19. Step 2 - Requirements • What does the customer want? • What will visitors want? • What does the customer really need? Enterprise PHP
  20. 20. Step 2 - Requirements Functional Design • Requirements Definition • Interaction Design / Wireframes • Flow Diagrams • Tip: Axure Enterprise PHP
  21. 21. Step 3 - Architecture Enterprise PHP
  22. 22. Step 3 - Architecture Don’t just start stacking bricks Enterprise PHP
  23. 23. Step 3 - Architecture Don’t just start stacking bricks Create an architecture first Enterprise PHP
  24. 24. Step 3 - Architecture Technical Design • Modeling • Class Diagrams • ER Diagrams (data model) • Collaboration Diagrams • Use Cases etc. • Tools: • UML • Whiteboards Enterprise PHP
  25. 25. Step 3 - Architecture High Level Architectures: • MVC (Model, View, Controller) • SOA (Service Oriented Architecture) • Multi-tier development (Frontend, Application, BL, Data) • CBD (Component Based Development) Enterprise PHP
  26. 26. Step 4 - Tools Enterprise PHP
  27. 27. Step 4 - Tools You don’t need tools… Enterprise PHP
  28. 28. Step 4 - Tools You don’t need tools… But they make you productive Enterprise PHP
  29. 29. Step 4 - Tools Development: • Eclipse PDT • Zend Studio • PhpEd • Vim • Komodo IDE’s versus Editors • Debugging & Profiling • Syntax Check • Cross-Referencing / Navigation Enterprise PHP
  30. 30. Step 4 - Tools Development: • Eclipse PDT • Zend Studio • PhpEd • Vim • Komodo IDE’s versus Editors • Debugging & Profiling • Syntax Check • Cross-Referencing / Navigation Enterprise PHP
  31. 31. Step 4 - Tools Enterprise PHP
  32. 32. Step 4 - Tools Source Control • CVS / SVN / MS VSS • Bitkeeper / GIT Enterprise PHP
  33. 33. Step 4 - Tools Source Control • CVS / SVN / MS VSS • Bitkeeper / GIT Documentation • phpDocumentor http://phpdoc.org • PHPXRef http://phpxref.sourceforge.net • Wiki http://en.wikipedia.org/wiki/List_of_wiki_software Enterprise PHP
  34. 34. Step 5 - Foundation Enterprise PHP
  35. 35. Step 5 - Foundation Start stacking bricks? • How many bricks does it take? • What about stability? Enterprise PHP
  36. 36. Step 5 - Foundation Start stacking bricks? • How many bricks does it take? • What about stability? Start with a foundation Enterprise PHP
  37. 37. Step 5 - Foundation Use a framework • Provides guidelines (frame) • Off the shelf components Examples • Zend Framework – http://framework.zend.com • ezComponents – http://ez.no/ezcomponents • Symfony – http://www.symfony-project.org • ATK – http://www.atk-framework.com Enterprise PHP
  38. 38. Step 5 - Foundation The “Not Invented Here” Syndrome: • “The existing frameworks are no good. I can do this better.” • “This framework is no good. It can do A through Y but I need Z.” • “This framework is too big. It provides A-Z but we only need A and B.” • “I know there's a good framework. But I would like to learn.” Enterprise PHP
  39. 39. Step 6 - Design Patterns Requirement 1056.4: We need to be able to look outside, but we can't make holes in the wall (rain should be kept outside). When it's sunny, a hole is ok. Enterprise PHP
  40. 40. Step 6 - Design Patterns Enterprise PHP
  41. 41. Step 6 - Design Patterns • A ‘window’ is a concept • Best practice way of solving a particular problem Enterprise PHP
  42. 42. Step 6 - Design Patterns • A ‘window’ is a concept • Best practice way of solving a particular problem • In IT, we call this a ‘design pattern’ Enterprise PHP
  43. 43. Step 6 - Design Patterns • A ‘window’ is a concept • Best practice way of solving a particular problem • In IT, we call this a ‘design pattern’ • Popular patterns in PHP: • MVC, Factory, Singleton, Registry, Decorator Enterprise PHP
  44. 44. Step 6 - Design Patterns • A ‘window’ is a concept • Best practice way of solving a particular problem • In IT, we call this a ‘design pattern’ • Popular patterns in PHP: • MVC, Factory, Singleton, Registry, Decorator • Good read: • php|architect's Guide to PHP Design Patterns - Jason E. Sweat Enterprise PHP
  45. 45. Step 7 - Testing Is your software tested after it has gone live? Enterprise PHP
  46. 46. Step 7 - Testing Various types of testing: • Developer testing • Functional testing • Environment testing • Performance testing • Usability testing Enterprise PHP
  47. 47. Step 7 - Testing A common scenario… Enterprise PHP
  48. 48. Step 7 - Testing The user complains… MWOEHA! BUG! Enterprise PHP
  49. 49. Step 7 - Testing Developer attacks the problem… fix_bug(); Enterprise PHP
  50. 50. Step 7 - Testing Problem Solved! Enterprise PHP
  51. 51. Step 7 - Testing Enterprise PHP
  52. 52. Step 7 - Testing • Solution: Unit Tests • Automated testing after each change • Prevents regressions Enterprise PHP
  53. 53. Step 7 - Testing • Solution: Unit Tests • Automated testing after each change • Prevents regressions • Testing for PHP applications: • PHPUnit http://www.phpunit.de/ • SimpleTest http://www.lastcraft.com/simple_test.php Enterprise PHP
  54. 54. Step 7 - Testing • Solution: Unit Tests • Automated testing after each change • Prevents regressions • Testing for PHP applications: • PHPUnit http://www.phpunit.de/ • SimpleTest http://www.lastcraft.com/simple_test.php • Continuous Integration: •CruiseControl http://cruisecontrol.sourceforge.net/ • phpUnderControl http://www.phpundercontrol.org/ Enterprise PHP
  55. 55. Step 7 - Testing • Test Driven Development 1. Define functionality 2. Create testcase 3. Run test => test fails 4. Implement functionality • Test succeeds? Done • Test fails? Refactor Repeat step 4 until finished Enterprise PHP
  56. 56. Step 8 - Optimization Users are reporting: quot;I work on the 197th floor. Every day I have to walk the stairs for 2 hours, then I have only 4 hours left to do my job.quot; Enterprise PHP
  57. 57. Step 8 - Optimization Solution: Elevator Enterprise PHP
  58. 58. Step 8 - Optimization Enterprise PHP
  59. 59. Step 8 - Optimization In PHP, this ‘elevator’ is called an ‘accelerator’ Enterprise PHP
  60. 60. Step 8 - Optimization In PHP, this ‘elevator’ is called an ‘accelerator’ • This is how PHP works (pseudo-ish code): read index.php; // enter the building compile index.php; // go to floor 197 echo “Hello World”; // get the job done Enterprise PHP
  61. 61. Step 8 - Optimization In PHP, this ‘elevator’ is called an ‘accelerator’ • This is how PHP works (pseudo-ish code): read index.php; // enter the building compile index.php; // go to floor 197 echo “Hello World”; // get the job done • An accelerator improves the first 2 steps Enterprise PHP
  62. 62. Step 8 - Optimization In PHP, this ‘elevator’ is called an ‘accelerator’ • This is how PHP works (pseudo-ish code): read index.php; // enter the building compile index.php; // go to floor 197 echo “Hello World”; // get the job done • An accelerator improves the first 2 steps • Accelerators for PHP: • APC http://pecl.php.net/package/APC • eAccelerator http://eaccelerator.net/ • Zend Platform http://www.zend.com/products/zend_platform Enterprise PHP
  63. 63. Step 8 - Optimization Users complain: “Every time I want coffee I have to go to the top floor to get some.” Enterprise PHP
  64. 64. Step 8 - Optimization Enterprise PHP
  65. 65. Step 8 - Optimization • Solution: • Create small coffee corners on every floor so people don’t have to go to the main restaurant every time. Enterprise PHP
  66. 66. Step 8 - Optimization • Solution: • Create small coffee corners on every floor so people don’t have to go to the main restaurant every time. • In PHP we call this caching • Don’t query the database everytime you need data • Use locally stored copy (file or memory) Enterprise PHP
  67. 67. Step 8 - Optimization • Solution: • Create small coffee corners on every floor so people don’t have to go to the main restaurant every time. • In PHP we call this caching • Don’t query the database everytime you need data • Use locally stored copy (file or memory) • PHP Caching solutions: •Zend_Cache http://framework.zend.com • Zend Platform http://www.zend.com/products/zend_platform • Memcached http://danga.com/memcached/ Enterprise PHP
  68. 68. Step 9 - Deployment • Lifecycle: • Develop • Test • Deploy to staging environment • Deploy to live • Use SVN • Code is just a part, don't forget the database • Create a 'Deployment & Release Profile' Enterprise PHP
  69. 69. Step 9 - Deployment System Architecture PHP MySQL Apache Linux From a simple single machine LAMP stack… Enterprise PHP
  70. 70. Step 9 - Deployment … to a High Availability, Scalable Architecture Enterprise PHP
  71. 71. Step 10 - Operations Monitoring: • Logfiles • Monitor infrastructure (tools such as Nagios) • Monitor application (tools such as Zend Platform) • Monitor business (is the money still pouring in?) Enterprise PHP
  72. 72. Step 10 - Operations Debugging • Ideal: “I had error x when I selected y after I clicked z” • Reality: “It doesn't work!” “What exactly doesn't work, and what did you do?” “It just ******** didn't work, FIX IT.” Enterprise PHP
  73. 73. Step 10 - Operations Solutions: • A ‘root cause’ analysis tool • Logging • Context Capture Enterprise PHP
  74. 74. Step 10 - Operations Change management: • Ticket system • Stick to your deployment - use the DRP • DON'T TOUCH THE LIVE ENVIRONMENT. EVAH! Enterprise PHP
  75. 75. The Big Picture (We’re almost done) Enterprise PHP
  76. 76. The Big Picture Enterprise PHP
  77. 77. The Big Picture • No ‘cowboy coding’, but structured steps • Higher quality • Software will be easier to maintain (and cheaper) Enterprise PHP
  78. 78. The Big Picture • No ‘cowboy coding’, but structured steps • Higher quality • Software will be easier to maintain (and cheaper) • Development methodology • Waterfall • Agile (DSDM, XP, Scrum) Enterprise PHP
  79. 79. The Big Picture • No ‘cowboy coding’, but structured steps • Higher quality • Software will be easier to maintain (and cheaper) • Development methodology • Waterfall • Agile (DSDM, XP, Scrum) • Software Development Life Cycle (SDLC) • Adapt from existing methods, learn from experts • Document it properly • Make it the cornerstone of your development efforts Enterprise PHP
  80. 80. More things to think about • Planning • Coding • Implementation • Security Enterprise PHP
  81. 81. Shameless Plug Book about this all: • php|architect’s Guide to Enterprise PHP Development • ISBN: 978-0-9738621-8-8 • Order at phparch.com or amazon.com • http://www.enterprisephp.nl Enterprise PHP
  82. 82. Questions? ivo@ibuildings.com http://www.ibuildings.com http://www.jansch.nl http://joind.in/talk/view/65 Enterprise PHP
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×