PHPEE?  The Enterprise PHP Architecture John Coggeshall Zend Technologies http://www.zend.com/
Who am I? <ul><li>Senior Technical Consultant for Zend </li></ul><ul><li>Author of PHP 5 Unleashed </li></ul><ul><li>Membe...
Why am I here? <ul><li>Obviously to talk about PHP in the Enterprise </li></ul><ul><li>But more to the point, where PHP fi...
Let's start off at the beginning <ul><li>A few things I've noticed: </li></ul><ul><ul><li>Defining what exactly is an “Ent...
What's Enterprise anyway <ul><li>Can you define “Enterprise” application? </li></ul><ul><li>Scalable </li></ul><ul><li>Lar...
What's Enterprise anyway <ul><li>Can you define “Enterprise” application? </li></ul><ul><li>Scalable </li></ul><ul><li>Lar...
A Definition I like..ish... <ul><li>From Martin Fowler's “Patterns of Enterprise Application Architecture”... </li></ul><u...
Devil in the Details <ul><li>Sounds like a great academic definition </li></ul><ul><ul><li>As always, the implementation i...
From Theory to Practice <ul><li>Whatever your definition of Enterprise is, someone has to actually design an implementatio...
Enterprise Architectures <ul><li>Is J2EE an Enterprise Architecture? </li></ul><ul><li>Is .NET an Enterprise Architecture?...
Design Patterns <ul><li>I'm pretty sure most of us know what these are. Formally they are defined as: </li></ul><ul><ul><l...
Enterprise Design Patterns Deal with the details Enterprise Design Patterns Deal with the details - Scalability - High Ava...
Enterprise Design Patterns <ul><li>Design Patterns can be applied to more than just working with OO code </li></ul><ul><li...
So..? <ul><li>J2EE is one application of design patterns to create an Enterprise Architecture </li></ul><ul><li>Accomplish...
Not everything is a nail <ul><li>While J2EE succeeds in many ways, it's really not designed for the “Web Problem” </li></u...
This is where PHP comes in <ul><li>In general, PHP developers can produce the same web site as a JSP developer in 25-50% l...
I'm not saying Java sucks <ul><li>It's not that Java/J2EE sucks, PHP is just better at the web problem </li></ul><ul><li>O...
The PHP / Java Bridge <ul><li>This is pretty sexy: </li></ul>
Using a Screwdriver <ul><li>If J2EE is really good at the back-end.. </li></ul><ul><li>... and PHP is really good at the f...
Example PHP/Java Architecture
For those who are pure PHP <ul><li>Of course PHP is more than able to develop Enterprise applications alone </li></ul><ul>...
PHP Specific Patterns <ul><li>There are a lot of Design Patterns which apply specifically to PHP in Enterprise Environment...
Scaling with MySQL <ul><li>I assume you know about MySQL. </li></ul><ul><ul><li>Replication is hot, if you do things right...
MySQL Architecture <ul><li>Often when writing Heavy-hitting PHP applications the biggest issue is the back-end database </...
MySQL Replication Pattern
MySQL Replication Pattern <ul><li>Works great, but you have to account for it in your PHP applications </li></ul><ul><ul><...
Leverage mod_rewrite <ul><li>If you're web application has a lot of semi-static content </li></ul><ul><ul><li>Content that...
Leverage mod_rewrite <ul><li>Most people in PHP would implement a page like this: </li></ul><ul><ul><li>http://www.example...
Leverage mod_rewrite <ul><li>Instead of generating the HTML for the browser, make this script generate another PHP script ...
Leverage mod_rewrite <ul><li>If you put them in this directory </li></ul><ul><ul><li>http://www.example.com/articles/5.php...
Leverage mod_rewrite <ul><li>Simple and Elegant Solution </li></ul><ul><li>Allows you to keep pages “personalized” </li></...
Improving PHP Performance <ul><li>Improving the speed of PHP can be done very easily using an opcode cache </li></ul>
So, if you want pure PHP
Or you have an existing back-end....
PHP  is  enterprise ready! Thank you! Questions? Buy My Book!
Upcoming SlideShare
Loading in …5
×

Enterprise PHP

3,490 views

Published on

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,490
On SlideShare
0
From Embeds
0
Number of Embeds
53
Actions
Shares
0
Downloads
85
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Enterprise PHP

  1. 1. PHPEE? The Enterprise PHP Architecture John Coggeshall Zend Technologies http://www.zend.com/
  2. 2. Who am I? <ul><li>Senior Technical Consultant for Zend </li></ul><ul><li>Author of PHP 5 Unleashed </li></ul><ul><li>Member of Zend Education Advisory Board </li></ul><ul><li>Maintainer of the Tidy, XMLRPCi, BLENC extensions for PHP 5 </li></ul>
  3. 3. Why am I here? <ul><li>Obviously to talk about PHP in the Enterprise </li></ul><ul><li>But more to the point, where PHP fits in the Enterprise stack </li></ul><ul><li>Make an attempt to clarify the differences between PHP 5 / J2EE / .NET </li></ul><ul><li>Drink Beer </li></ul>
  4. 4. Let's start off at the beginning <ul><li>A few things I've noticed: </li></ul><ul><ul><li>Defining what exactly is an “Enterprise Application” is pretty difficult </li></ul></ul><ul><ul><li>People mistake “Enterprise Applications” for technologies employing things such as J2EE / .NET / PHP </li></ul></ul><ul><ul><li>People don't identify Enterprise Architectures as a collection of patterns </li></ul></ul>
  5. 5. What's Enterprise anyway <ul><li>Can you define “Enterprise” application? </li></ul><ul><li>Scalable </li></ul><ul><li>Large </li></ul><ul><li>Object Oriented </li></ul><ul><li>Oracle-based </li></ul><ul><li>Distributed </li></ul><ul><li>Cash-Cow </li></ul><ul><li>High Availability </li></ul><ul><li>Java Based </li></ul><ul><li>Complex </li></ul><ul><li>Many Users </li></ul>
  6. 6. What's Enterprise anyway <ul><li>Can you define “Enterprise” application? </li></ul><ul><li>Scalable </li></ul><ul><li>Large </li></ul><ul><li>Object Oriented </li></ul><ul><li>Oracle-based </li></ul><ul><li>Distributed </li></ul><ul><li>Cash-Cow </li></ul><ul><li>High Availability </li></ul><ul><li>Java Based </li></ul><ul><li>Complex </li></ul><ul><li>Many Users </li></ul>Does any of those things really define much of anything to you?
  7. 7. A Definition I like..ish... <ul><li>From Martin Fowler's “Patterns of Enterprise Application Architecture”... </li></ul><ul><li>A lot of data </li></ul><ul><li>Persistent data </li></ul><ul><li>Access to Data Concurrently </li></ul><ul><li>Integration </li></ul>
  8. 8. Devil in the Details <ul><li>Sounds like a great academic definition </li></ul><ul><ul><li>As always, the implementation is just a little more complex </li></ul></ul><ul><li>Implied Characteristics </li></ul><ul><ul><li>Scalability </li></ul></ul><ul><ul><li>Availability </li></ul></ul><ul><ul><li>Integrity </li></ul></ul>
  9. 9. From Theory to Practice <ul><li>Whatever your definition of Enterprise is, someone has to actually design an implementation </li></ul><ul><li>A lot of people mistake implementations for the definition </li></ul><ul><ul><li>That ends up costing them a lot of money they might not have otherwise spent. </li></ul></ul>
  10. 10. Enterprise Architectures <ul><li>Is J2EE an Enterprise Architecture? </li></ul><ul><li>Is .NET an Enterprise Architecture? </li></ul><ul><li>Short answer: Sure </li></ul><ul><li>Longer Answer: They are implementations of a set of Enterprise Design Patterns </li></ul>
  11. 11. Design Patterns <ul><li>I'm pretty sure most of us know what these are. Formally they are defined as: </li></ul><ul><ul><li>A name </li></ul></ul><ul><ul><li>The core of a problem it aims to solve </li></ul></ul><ul><ul><li>The core of the solution to that problem </li></ul></ul><ul><ul><li>The consequences of using that solution </li></ul></ul>
  12. 12. Enterprise Design Patterns Deal with the details Enterprise Design Patterns Deal with the details - Scalability - High Availability - Integrity
  13. 13. Enterprise Design Patterns <ul><li>Design Patterns can be applied to more than just working with OO code </li></ul><ul><li>They can be applied to conceptual architectures </li></ul><ul><li>Could be implemented by any language with the aforementioned Enterprise capabilities </li></ul>
  14. 14. So..? <ul><li>J2EE is one application of design patterns to create an Enterprise Architecture </li></ul><ul><li>Accomplishes most of the goals required by large-scale Enterprise applications </li></ul><ul><li>But: Generic Problems Lead to Generic Solutions </li></ul>
  15. 15. Not everything is a nail <ul><li>While J2EE succeeds in many ways, it's really not designed for the “Web Problem” </li></ul><ul><li>The amount of effort put into even simple applications is crazy </li></ul><ul><li>There are simpler ways to do this stuff </li></ul>
  16. 16. This is where PHP comes in <ul><li>In general, PHP developers can produce the same web site as a JSP developer in 25-50% less time </li></ul><ul><li>That's not BS either </li></ul><ul><ul><li>PayPal's Sample Integration for PHP took me about 8 days, the Java guy had been working on it for about a month. </li></ul></ul>
  17. 17. I'm not saying Java sucks <ul><li>It's not that Java/J2EE sucks, PHP is just better at the web problem </li></ul><ul><li>On the other hand, PHP pretty much sucks at the Enterprise backend problem </li></ul><ul><li>But with our power's combined.... </li></ul>♥ Java
  18. 18. The PHP / Java Bridge <ul><li>This is pretty sexy: </li></ul>
  19. 19. Using a Screwdriver <ul><li>If J2EE is really good at the back-end.. </li></ul><ul><li>... and PHP is really good at the front end </li></ul><ul><li>... and they can play nice together </li></ul><ul><li>I think you get the picture </li></ul><ul><li>Remember, you can implement the same design patterns in PHP 5 as you do in J2EE! </li></ul>
  20. 20. Example PHP/Java Architecture
  21. 21. For those who are pure PHP <ul><li>Of course PHP is more than able to develop Enterprise applications alone </li></ul><ul><li>Many of the same patterns that apply to J2EE/.NET will work the same in PHP </li></ul><ul><li>To answer: PHP works great in Enterprise environments, it just doesn't force you into a pre-designed mold (good and bad) </li></ul>
  22. 22. PHP Specific Patterns <ul><li>There are a lot of Design Patterns which apply specifically to PHP in Enterprise Environments </li></ul><ul><li>Esp. when dealing with specific types of technology (Apache, MySQL, etc). </li></ul><ul><li>Let's check a few of them out </li></ul>
  23. 23. Scaling with MySQL <ul><li>I assume you know about MySQL. </li></ul><ul><ul><li>Replication is hot, if you do things right in PHP </li></ul></ul><ul><li>Scales great until your writes exceed what can be done on a single machine </li></ul><ul><ul><li>That's almost not true anymore, but for now it is. </li></ul></ul>
  24. 24. MySQL Architecture <ul><li>Often when writing Heavy-hitting PHP applications the biggest issue is the back-end database </li></ul><ul><li>When doing a pure PHP implementation, good MySQL knowledge is important </li></ul><ul><li>Let's look at a great MySQL architectural pattern </li></ul>
  25. 25. MySQL Replication Pattern
  26. 26. MySQL Replication Pattern <ul><li>Works great, but you have to account for it in your PHP applications </li></ul><ul><ul><li>Application DB abstractions should provide different facilities at the API level for reading/writing to the DB and perhaps a third for FULLTEXT searching </li></ul></ul><ul><ul><li>Even if you don't need it now, a little planning goes a long way </li></ul></ul>
  27. 27. Leverage mod_rewrite <ul><li>If you're web application has a lot of semi-static content </li></ul><ul><ul><li>Content that could change so it has to be stored in the DB, but almost never does </li></ul></ul><ul><li>.. And you're running on Apache </li></ul><ul><li>This Design Pattern is killer! </li></ul>
  28. 28. Leverage mod_rewrite <ul><li>Most people in PHP would implement a page like this: </li></ul><ul><ul><li>http://www.example.com/show_article.php?id=5 </li></ul></ul><ul><li>This would be responsible for generating the semi-static page HTML for the browser </li></ul>
  29. 29. Leverage mod_rewrite <ul><li>Instead of generating the HTML for the browser, make this script generate another PHP script that contains mostly static content </li></ul><ul><ul><li>Keep things like personalization code, but make the actual article itself static in the file </li></ul></ul><ul><ul><li>Write the file to disk in a public folder under document root </li></ul></ul>
  30. 30. Leverage mod_rewrite <ul><li>If you put them in this directory </li></ul><ul><ul><li>http://www.example.com/articles/5.php </li></ul></ul><ul><li>You can create a mod_rewrite rule such that </li></ul><ul><ul><li>http://www.example.com/articles/5.php maps to </li></ul></ul><ul><ul><li>http://www.example.com/show_article.php?id=5 </li></ul></ul><ul><li>Since show_article.php writes files to articles, once it's been generated no more DB reads! </li></ul>
  31. 31. Leverage mod_rewrite <ul><li>Simple and Elegant Solution </li></ul><ul><li>Allows you to keep pages “personalized” </li></ul><ul><li>Very easy to Maintain </li></ul><ul><li>Credit goes to Theo Schlossnagle (?) </li></ul>
  32. 32. Improving PHP Performance <ul><li>Improving the speed of PHP can be done very easily using an opcode cache </li></ul>
  33. 33. So, if you want pure PHP
  34. 34. Or you have an existing back-end....
  35. 35. PHP is enterprise ready! Thank you! Questions? Buy My Book!

×