Enterprise PHP Development - ZendCon 2008
-
Upload
ivo-jansch -
Category
Technology
-
view
7.817 -
download
0
description
Transcript of Enterprise PHP Development - ZendCon 2008
![Page 2: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/2.jpg)
Enterprise PHP
About me• Ibuildings:
• PHP services (dev, training, consulting)
• “Professionalizing PHP usage”
• Based in Europe (4 offices in UK and NL)
• 65 people, 40 devs/consultants (mostly ZCE)
• Me:
• CTO at Ibuildings
• Author at php|architect
• Geek
• Blogger
![Page 3: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/3.jpg)
Enterprise PHP
What’s an Enterprise?“Any of several ships by that name
in the Star Trek universe” – Wikipedia
“A business, company or comparable organization”
![Page 4: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/4.jpg)
Enterprise PHP
PHP usage is changing• 1998
• Personal stuff
• 2003• Simple websites
• Content management
• Blogs
• 2008• Big websites
• Banks
• Insurance Companies
![Page 5: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/5.jpg)
Enterprise PHP
PHP’s Quest so far
Enterprise
SME
SOHO
![Page 6: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/6.jpg)
Enterprise PHP
Is PHP ‘enterprise ready’?
![Page 7: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/7.jpg)
Enterprise PHP
Is PHP ‘enterprise ready’?
Small Lightweight Cheap Easy to learn
Big Enterprise friendly enterpriCe CS required
![Page 8: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/8.jpg)
Enterprise PHP
A word from my girlfriend
It's not the SIZE of the tool...
It's how you USE it.
![Page 9: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/9.jpg)
Enterprise PHP
Traditional PHP metaphor
PHP is like LEGO bricks
![Page 10: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/10.jpg)
Enterprise PHP
Improved metaphor
PHP is no longer a toy
Let’s use the metaphor of actual bricks
![Page 11: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/11.jpg)
Enterprise PHP
About Bricks
• Extreme Simplicity
• Easy to learn
• Versatile
• Cheap
![Page 12: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/12.jpg)
Enterprise PHP
Enterprise Development
In 10 steps
![Page 13: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/13.jpg)
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 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 14: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/14.jpg)
Enterprise PHP
Step 1 – The Team
• Be a Software Engineer
• Train your skills
• Study OO principles
• Consider Zend Certification
![Page 15: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/15.jpg)
Enterprise PHP
Step 2 - Requirements
• What does the customer want?
• What will visitors want?
• What does the customer really need?
![Page 16: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/16.jpg)
Enterprise PHP
Step 2 - Requirements
Functional Design• Requirements Definition
• Interaction Design / Wireframes
• Flow Diagrams
• Tip: Axure
![Page 17: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/17.jpg)
Enterprise PHP
Step 3 - Architecture
Don’t just start stacking bricks
Create an architecture first
![Page 18: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/18.jpg)
Technical Design• Modeling
• Class Diagrams
• ER Diagrams (data model)
• Collaboration Diagrams
• Use Cases etc.
• Tools:
• UML
• Whiteboards
Enterprise PHP
Step 3 - Architecture
![Page 19: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/19.jpg)
Enterprise PHP
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)
![Page 20: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/20.jpg)
Enterprise PHP
Step 4 - Tools
You don’t need tools…
But they make you productive
![Page 21: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/21.jpg)
Enterprise PHP
Step 4 - Tools
Development:• Eclipse PDT
• Zend Studio
• PhpEd
• Vim
• Komodo
IDE’s versus Editors• Debugging & Profiling
• Syntax Check
• Cross-Referencing / Navigation
![Page 22: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/22.jpg)
Enterprise PHP
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
![Page 23: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/23.jpg)
Enterprise PHP
Step 5 - Foundation
Start stacking bricks?• How many bricks does it take?
• What about stability?
Start with a foundation
![Page 24: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/24.jpg)
Enterprise PHP
Step 5 - FoundationUse 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
![Page 25: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/25.jpg)
Enterprise PHP
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 26: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/26.jpg)
Enterprise PHP
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 27: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/27.jpg)
Enterprise PHP
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 28: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/28.jpg)
Enterprise PHP
Step 7 - Testing
Is your software tested after it has gone live?
![Page 29: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/29.jpg)
Enterprise PHP
Step 7 - Testing
Various types of testing:• Developer testing
• Functional testing
• Environment testing
• Performance testing
• Usability testing
![Page 30: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/30.jpg)
Enterprise PHP
Step 7 - Testing
A common scenario…
![Page 31: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/31.jpg)
Enterprise PHP
Step 7 - Testing
The user complains…
MWOEHA! BUG!
![Page 32: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/32.jpg)
Enterprise PHP
Step 7 - Testing
Developer attacks the problem…
fix_bug();
![Page 33: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/33.jpg)
Enterprise PHP
Step 7 - Testing
Problem Solved!
![Page 34: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/34.jpg)
Enterprise PHP
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/
![Page 35: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/35.jpg)
Enterprise PHP
Step 7 - Testing
• Test Driven Development1. 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 36: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/36.jpg)
Enterprise PHP
Step 8 - Optimization
Users are reporting:
"I work on the 197th floor. Every day Ihave to walk the stairs for 2 hours, then I
have only 4 hours left to do my job."
![Page 37: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/37.jpg)
Enterprise PHP
Step 8 - Optimization
Solution: Elevator
![Page 38: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/38.jpg)
Enterprise PHP
Step 8 - Optimization
In PHP, this ‘elevator’ is called an ‘accelerator’
• This is how PHP works (pseudo-ish code):read index.php; // enter the buildingcompile index.php; // go to floor 197echo “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
![Page 39: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/39.jpg)
Enterprise PHP
Step 8 - Optimization
Users complain:
“Every time I want coffee I have to go to the top floor to get some.”
![Page 40: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/40.jpg)
Enterprise PHP
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/
![Page 41: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/41.jpg)
Enterprise PHP
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 42: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/42.jpg)
Enterprise PHP
Step 9 - Deployment
System Architecture
From a simple single machine LAMP stack…
PHP
Apache
Linux
MySQL
![Page 43: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/43.jpg)
Enterprise PHP
Step 9 - Deployment
… to a High Availability, Scalable Architecture
![Page 44: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/44.jpg)
Enterprise PHP
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 45: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/45.jpg)
Enterprise PHP
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 46: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/46.jpg)
Enterprise PHP
Step 10 - Operations
Solutions:• A ‘root cause’
analysis tool
• Logging
• Context Capture
![Page 47: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/47.jpg)
Enterprise PHP
Step 10 - Operations
Change management:
• Ticket system
• Stick to your deployment - use the DRP
• DON'T TOUCH THE LIVE ENVIRONMENT. EVAH!
![Page 48: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/48.jpg)
Enterprise PHP
The Big Picture
(We’re almost done)
![Page 49: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/49.jpg)
Enterprise PHP
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
![Page 50: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/50.jpg)
Enterprise PHP
More things to think about
• Planning
• Coding
• Implementation
• Security
![Page 51: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/51.jpg)
Enterprise PHP
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
![Page 52: Enterprise PHP Development - ZendCon 2008](https://reader030.fdocument.pub/reader030/viewer/2022020306/5538969c550346722e8b4861/html5/thumbnails/52.jpg)
Enterprise PHP
Questions?
http://www.ibuildings.com
http://www.jansch.nl