enterprise php development - ivo jansch
DESCRIPTION
TRANSCRIPT
![Page 1: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/1.jpg)
Ibuildings - http://www.ibuildings.com
Enterprise PHP development
Ivo Jansch <[email protected]>
Dutch PHP Conference, June 14, 2008
![Page 2: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/2.jpg)
Tuesday, February 26, 2008 2
What's an enterprise?
• Wikipedia: “Any of several ships by that name in the Star Trek
fictional universe”
“A business, company, or comparable organization”
![Page 3: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/3.jpg)
Tuesday, February 26, 2008 3
Is PHP Enterprise ready?
• CIO Magazine:
“PHP works well for prototyping because it is easy to get a site up and running. Use PHP to design the site [...] but when it comes time for development, tell the team you want the result to look and act like this PHP site...but in Java”
(Or: “great, this is exactly what I need! now do it again, at twice the cost!”)
http://www.cio.com/article/176250 (skip the article, read the comments)
![Page 4: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/4.jpg)
Tuesday, February 26, 2008 4
Is PHP Enterprise ready?
Small Lightweight Cheap Easy to learn
Big Enterprise friendly enterpriCe CS required
![Page 5: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/5.jpg)
Tuesday, February 26, 2008 5
A word from my girlfriend
It's not the
SIZE
of the tool...
It's how you USE it.
![Page 6: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/6.jpg)
Tuesday, February 26, 2008 6
PHP is changing...
• 1998 Personal stuff
• 2003 Simple websites Content management Blogs
• 2008 Big websites Banks Insurance Companies ...
![Page 7: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/7.jpg)
Tuesday, February 26, 2008 7
PHP is changing...
• Traditional metaphor PHP is like Lego bricks
Bricks allowing you to build anything
![Page 8: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/8.jpg)
Tuesday, February 26, 2008 8
PHP is changing...
• PHP is no longer a toy Let’s use the metaphor of actual bricks
Because we’re building actual buildings now
![Page 9: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/9.jpg)
Tuesday, February 26, 2008 9
About Bricks
• Extreme simplicity • Easy to learn • Versatile • Cheap
... so building a skyscraper must be peanuts, right?
![Page 10: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/10.jpg)
Ibuildings - http://www.ibuildings.com
Enterprise development in 10 steps
![Page 11: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/11.jpg)
Tuesday, February 26, 2008 11
Step 1 – The Team
“Dear Mr. Businessman,
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.”
![Page 12: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/12.jpg)
Tuesday, February 26, 2008 12
Step 1 – The Team
• Be a software engineer
• Train your skills
• Study OO principles
• Consider Zend Certification
![Page 13: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/13.jpg)
Tuesday, February 26, 2008 13
Step 2 - Requirements
• What does the customer need? • What do visitors want?
![Page 14: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/14.jpg)
Tuesday, February 26, 2008 14
Step 2 - Requirements
• Functional Design Requirements definition
Interaction Design / Wireframes
Flow diagrams
![Page 15: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/15.jpg)
Tuesday, February 26, 2008 15
Step 3 - Architecture
• Don’t just start stacking bricks
• Create an architecture first
![Page 16: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/16.jpg)
Tuesday, February 26, 2008 16
Step 3 - Architecture
• Technical Design Modelling
• Class diagrams • ER diagram (data model) • Colaboration diagrams • Use cases • etc.
Tools: UML, whiteboards
![Page 17: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/17.jpg)
Tuesday, February 26, 2008 17
Step 3 - Architecture
• High Level Architectures:
MVC (Model View Controller)
SOA (Service Oriented Architecture)
Multi-tier development (Frontend, Application, Data)
CBD (Component Based Development)
![Page 18: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/18.jpg)
Tuesday, February 26, 2008 18
Step 4 - Tools
• You don’t need tools...
• But they make you productive
![Page 19: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/19.jpg)
Tuesday, February 26, 2008 19
Step 4 - Tools
• Development: Eclipse (PDT) PhpED Vim Zend Studio Komodo
• IDE's vs Editors Debugging Profiling Navigation / cross references Syntax Checking
![Page 20: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/20.jpg)
Tuesday, February 26, 2008 20
Step 4 - Tools
• Source Control CVS / SVN Bitkeeper / GIT
Branching Tagging
![Page 21: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/21.jpg)
Tuesday, February 26, 2008 21
Step 5 - Foundation
• Start stacking bricks? How many bricks does it take.. What about stability?
• Start with a foundation
![Page 22: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/22.jpg)
Tuesday, February 26, 2008 22
Step 5 - Foundation
• Use a framework Provides guidelines (frame) Off the shelf components
• Examples Zend Framework http://framework.zend.com
CakePHP http://http://www.cakephp.org
ezComponents http://ez.no/ezcomponents
Symfony http://www.symfony-project.org
ATK http://www.achievo.org/atk
![Page 23: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/23.jpg)
Tuesday, February 26, 2008 23
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.”
![Page 24: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/24.jpg)
Tuesday, February 26, 2008 24
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.
![Page 25: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/25.jpg)
Tuesday, February 26, 2008 25
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
![Page 26: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/26.jpg)
Tuesday, February 26, 2008 26
Step 7 - Testing
• Is your software tested after it has gone live?
![Page 27: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/27.jpg)
Tuesday, February 26, 2008 27
Step 7 - Testing
• Various types of testing
Developer testing
Functional testing
Environment testing
Performance testing
Usability testing
![Page 28: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/28.jpg)
Tuesday, February 26, 2008 28
Step 7 - Testing
• Common scenario
![Page 29: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/29.jpg)
Tuesday, February 26, 2008 29
Step 7 - Testing
• User complains...
MWOEHA! BUG!
![Page 30: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/30.jpg)
Tuesday, February 26, 2008 30
Step 7 - Testing
• Developer attacks the problem
fix_bug();
![Page 31: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/31.jpg)
Tuesday, February 26, 2008 31
Step 7 - Testing
• Problem solved!
![Page 32: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/32.jpg)
Tuesday, February 26, 2008 32
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 with phpUnderControl Xinc http://code.google.com/p/xinc/
![Page 33: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/33.jpg)
Tuesday, February 26, 2008 33
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
![Page 34: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/34.jpg)
Tuesday, February 26, 2008 34
Step 8 - Optimization
Users are reporting:
"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."
![Page 35: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/35.jpg)
Tuesday, February 26, 2008 35
Step 8 - Optimization
• Solution: Elevator
![Page 36: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/36.jpg)
Tuesday, February 26, 2008 36
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: • eAccelerator http://eaccelerator.net/
• APC http://pecl.php.net/package/APC
• Zend Platform http://www.zend.com/products/zend_platform
![Page 37: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/37.jpg)
Tuesday, February 26, 2008 37
Step 8 - Optimization
Users complain:
“Every time I need coffee I have to go to the top floor to get some.”
![Page 38: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/38.jpg)
Tuesday, February 26, 2008 38
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
Smarty http://smarty.php.net
Zend Platform http://www.zend.com/products/zend_platform
Memcached http://danga.com/memcached/
![Page 39: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/39.jpg)
Tuesday, February 26, 2008 39
Step 9 - Deployment
• Lifecycle: Develop Test Deploy to acceptance test environment Deploy to live
• Use SVN
• Code is just a part, don't forget the database
• Create a 'Deployment & Release Profile'
![Page 40: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/40.jpg)
Tuesday, February 26, 2008 40
Step 9 - Deployment
• System Architecture
PHP
Apache
Linux
MySQL
From a simple LAMP stack on a single machine...
![Page 41: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/41.jpg)
Tuesday, February 26, 2008 41
Step 9 - Deployment
• System Architecture
... to a High Availability, Horizontally Scalable architecture
![Page 42: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/42.jpg)
Tuesday, February 26, 2008 42
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?)
![Page 43: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/43.jpg)
Tuesday, February 26, 2008 43
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.”
![Page 44: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/44.jpg)
Tuesday, February 26, 2008 44
Step 10 - Operations
• Solution
A 'root cause analysis' tool
![Page 45: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/45.jpg)
Tuesday, February 26, 2008 45
Step 10 - Operations
• Change management Ticket system Stick to your deployment - use the DRP
DON'T TOUCH THE LIVE ENVIRONMENT.
But I absolutely have to...
DON'T!
but...
NO! IF YOU TOUCH IT, YOU WILL LOSE ALL GURU POINTS.
![Page 46: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/46.jpg)
46
Shameless self-promotion • php|architect's
Guide to Enterprise PHP Development
• PDF: June 12, Print: June 26
• ISBN: 978-0-9738621-8-8
• Order via http://phparch.com
• http://www.enterprisephp.nl
![Page 47: Enterprise PHP Development - Ivo Jansch](https://reader033.vdocuments.net/reader033/viewer/2022061215/54804a0d5906b503298b46cd/html5/thumbnails/47.jpg)
Ibuildings - http://www.ibuildings.com
Questions?
http://www.jansch.nl http://www.enterprisephp.nl http://www.ibuildings.com