Developing Easily Deployable PHP Applications<br />John Mertic<br />@2011 SugarCRM Inc. All rights reserved.<br />
Who Am I?<br />John Mertic<br />Contact Info<br />http://jmertic.wordpress.com<br />Twitter: @jmertic<br />jmertic@sugarcr...
Why deployable apps still matter<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />3<br />Source: http://w...
What I’ll cover<br />Writing portable code ( or at least trying to )<br />Enabling configuration and customization ( for u...
Writing portable code<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />5<br />Source: http://www.flickr.c...
Define your support matrix<br />Operating System<br />Any Linux, UNIX, OS X<br />Windows<br />Web Server<br />Apache 1.3, ...
Design code that works for these platforms<br />Avoid writing code directly talking to the bare metal; Abstract like mad! ...
Example of what we have to work around<br />Fetching a record from a database<br />Mysql - mysql_fetch_assoc()<br />Mysqli...
Build and deploy!<br />We build all 3 editions of SugarCRM from 1 codebase<br />We add code tags around sections specific ...
Enabling configuration and customization<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />10<br />Source:...
Making it simple yet powerful for end users<br />Expose configuration options thru multiple channels<br />Remember, not ev...
Making it simple yet powerful for developers<br />Create a safe place to make customizations<br />Avoid painful upgrades<b...
Strategies for testing and QA<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />13<br />Source: http://www...
Automated Testing Tools<br />Jenkins (http://jenkins-ci.org/) – Extensible CI Server<br />Running on every checkin<br />PH...
Non-automated testing<br />You need to actually have people use your app.<br />We do all of the following:<br />Code revie...
Making your code perform well<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />16<br />Source: http://www...
What we do to help performance<br />Try to do the basic stuff<br />Avoid writing slow code<br />Caching where appropriate<...
How we gauge performance<br />Formal testing<br />Use Jmeter (http://jakarta.apache.org/jmeter/) on a load test cluster to...
What are the lessons we have learned?<br />Define what you will support and to what extent<br />Write your code to be as f...
Questions?<br />Slides available on SlideShare<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />20<br />
Upcoming SlideShare
Loading in …5
×

POSSCON 2011 - Developing Easily Deployable PHP Applications

1,715 views

Published on

Here's the scenario: you've wrote a PHP application that is designed to run on Linux, Apache, and MySQL Now you have a customer that wants to run it on Windows. Or using Oracle. Or they like Memcache instead of APC. How do you do it, without sacrificing performance, stability, simplicity, and your own sanity? And what development and testing practices should you use to make such a project a success?

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

  • Be the first to like this

No Downloads
Views
Total views
1,715
On SlideShare
0
From Embeds
0
Number of Embeds
483
Actions
Shares
0
Downloads
12
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • People fear the cloudPeople can’t use the cloudPeople want to use different cloudsOur customer base reflects this ( 1/3 sugar cloud, 1/3 on site, 1/3 on other clouds )
  • User base is diverse, likes different offerings, and will move between them.Lots of choices ( Web Servers / OSes / Databases / PHP versions ) as well as config possibilitiesHave to cover lots of platforms; can rely on particular hardware or software being available.
  • Relate in picture, mention about balance for needed control and simplicity.Talk about how we made this a big deal in Sugar 6
  • Types of testing we useTesting is hard
  • Performance story about GNs; very particular to make go fastNeed to balance performance and configurability; make the performance choices that make the most difference, and enable ways for those working with your software to make more.
  • Try to avoid subqueries as much as possible.
  • POSSCON 2011 - Developing Easily Deployable PHP Applications

    1. 1. Developing Easily Deployable PHP Applications<br />John Mertic<br />@2011 SugarCRM Inc. All rights reserved.<br />
    2. 2. Who Am I?<br />John Mertic<br />Contact Info<br />http://jmertic.wordpress.com<br />Twitter: @jmertic<br />jmertic@sugarcrm.com ( Sugar )<br />jmertic@php.net ( PHP )<br />I am the Community Manager for SugarCRM<br />http://www.sugarcrm.com<br />http://developers.sugarcrm.com<br />Learn more about working with the SugarCRM platform during tomorrow’s session “SugarCRM: Your Next Business Application”<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />2<br />Buy my book!<br />http://amzn.to/enioPV<br />
    3. 3. Why deployable apps still matter<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />3<br />Source: http://www.flickr.com/photos/sarchi/220539933<br />
    4. 4. What I’ll cover<br />Writing portable code ( or at least trying to )<br />Enabling configuration and customization ( for users and developers )<br />Strategies for testing and QA<br />Making your code perform (reasonably) well<br />@2011 SugarCRM Inc. All rights reserved.<br />3/24/2011<br />4<br />
    5. 5. Writing portable code<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />5<br />Source: http://www.flickr.com/photos/25339258@N05/2389910825/<br />
    6. 6. Define your support matrix<br />Operating System<br />Any Linux, UNIX, OS X<br />Windows<br />Web Server<br />Apache 1.3, 2.0, 2.2<br />IIS 6/7 using FastCGI<br />Database<br />MySQL 5.x<br />SQL Server 2005, 2008<br />Oracle 10g, 11g<br />PHP<br />5.2.x, 5.3.x<br />Support most common configurations options<br />mbstring.func_overload<br />error_reporting = E_ALL<br />Require only the most mainline extensions, plus<br />Mbstrings ( i18n support )<br />Imap ( mail support )<br />Specific database extension ( mysql, mysqli, oci8, mssql, sqlsrv )<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />6<br />
    7. 7. Design code that works for these platforms<br />Avoid writing code directly talking to the bare metal; Abstract like mad! <br />Use a DB abstraction layer or ORM<br />Make sure PHP features you are using are supported across support matrix or provide an alternate implementation.<br />Detect what else the server has for you to use, have abstraction layer to talk to them.<br />Example: User cache <br />( APC, Memcache, Wincache, etc)<br />Assume very little about the underlying system<br />Example: Treat file system as case-sensitive, and file writes are only in one area.<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />7<br />
    8. 8. Example of what we have to work around<br />Fetching a record from a database<br />Mysql - mysql_fetch_assoc()<br />Mysqli - mysqli_fetch_assoc()<br />Mssql - mssql_fetch_assoc()<br />Oci8 - oci_fetch_array()<br />Sqlsrv - sqlsrv_fetch_array()<br />Problems we run into<br />Each has different input parameters<br />What gets returned if no rows available?<br />Mysql– bool false<br />Mysqli - null<br />Mssql– bool false<br />Oci8 – bool false<br />Sqlsrv– null ( bool false if error )<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />8<br />
    9. 9. Build and deploy!<br />We build all 3 editions of SugarCRM from 1 codebase<br />We add code tags around sections specific to a certain version.<br />To test under each different edition, developers can run the build locally<br />We also can tag in or out features on a per edition basis.<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />9<br />Source: http://www.flickr.com/photos/eastcapital/4554220770/<br />
    10. 10. Enabling configuration and customization<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />10<br />Source: http://www.flickr.com/photos/miskypig/400004362/<br />
    11. 11. Making it simple yet powerful for end users<br />Expose configuration options thru multiple channels<br />Remember, not everyone has source access<br />Allow users to customize their UI interface easily<br />Make what should be simple, simple<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />11<br />
    12. 12. Making it simple yet powerful for developers<br />Create a safe place to make customizations<br />Avoid painful upgrades<br />Create an easy to use API<br />Well defined and documented.<br />Don’t break it!<br />Create easy to use hooks for modifying / adding functionality<br />Examples from SugarCRM include:<br />Metadata driven views<br />Logic Hooks<br />Allow for internationalization and localization<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />12<br />
    13. 13. Strategies for testing and QA<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />13<br />Source: http://www.flickr.com/photos/cglock/386033158/<br />
    14. 14. Automated Testing Tools<br />Jenkins (http://jenkins-ci.org/) – Extensible CI Server<br />Running on every checkin<br />PHP lint ( php –l ) – Syntax checking for PHP source files<br />PHPUnit (http://www.phpunit.de/) – Unit testing framework<br />Runs once a day<br />SODA – functional testing framework that leverages Watir<br />SodaMachine – GUI tool for building SODA tests<br />JMeter (http://jakarta.apache.org/jmeter/) - tool for testing a website under high load<br />MeterMaid – XML language to write JMeter tests in<br />SugarMMM (MeterMaid Maker) - utility to automate writing MeterMaid tests for SugarCRM<br />TidBit – tool to make huge datasets for testing<br />Learn more about SugarCRM’sopen source tools at http://developers.sugarcrm.com/opensource<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />14<br />
    15. 15. Non-automated testing<br />You need to actually have people use your app.<br />We do all of the following:<br />Code reviews<br />Design reviews<br />Partner and customer demos<br />Community previews<br />Earlier the feedback, the better<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />15<br />
    16. 16. Making your code perform well<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />16<br />Source: http://www.flickr.com/photos/tech1987/501427718/<br />
    17. 17. What we do to help performance<br />Try to do the basic stuff<br />Avoid writing slow code<br />Caching where appropriate<br />Combine, minify, and version JS / CSS / images<br />Keep SQL queries as simple as possible<br />Leave the rest to the Sys Admin<br />Provide configuration options to turn off heavy features<br />Enable the application to take advantage of it’s environment<br />Example: Using APC, memcache, Zend_Cache, wincache with little to no configuration<br />Provide best practices for various environments<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />17<br />
    18. 18. How we gauge performance<br />Formal testing<br />Use Jmeter (http://jakarta.apache.org/jmeter/) on a load test cluster to test raw response speed.<br />Instance analysis<br />Monitor web server logs to look for non-cached items<br />Track slow queries<br />Ad-hoc testing<br />Profile PHP execution with XDebug<br />Use Firebug to measure CSS / JS / image payload<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />18<br />
    19. 19. What are the lessons we have learned?<br />Define what you will support and to what extent<br />Write your code to be as flexible as possible<br />Make customizing, configuring, and extending your application not painful for users or developers<br />Test across your support matrix, using automation when it makes sense<br />Focus more on best practices and general performance, let admins handle it from there.<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />19<br />Source: http://www.flickr.com/photos/dlanod/126386070/<br />
    20. 20. Questions?<br />Slides available on SlideShare<br />3/24/2011<br />@2011 SugarCRM Inc. All rights reserved.<br />20<br />

    ×