phpnw 2010 - developing easily deployable php applications

19
Developing Easily Deployable PHP Applications John Mertic - SugarCRM http://joind.in/2059 @2010 SugarCRM Inc. All rights reserved.

Upload: john-mertic

Post on 05-Dec-2014

3.407 views

Category:

Technology


2 download

DESCRIPTION

Here’s the scenario: you’ve written a PHP application designed to run on Linux, Apache, and MySQL. Now you have a customer who 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?In this talk we’ll look at how we approached solving this problem at SugarCRM and what lessons we learned in the process.

TRANSCRIPT

Page 1: PHPNW 2010 - Developing Easily Deployable PHP Applications

Developing Easily Deployable PHP Applications

John Mertic - SugarCRM

http://joind.in/2059

@2010 SugarCRM Inc. All rights reserved.

Page 2: PHPNW 2010 - Developing Easily Deployable PHP Applications

Why deployable apps still matter

7/22/2010 @2010 SugarCRM Inc. All rights reserved. 2

Page 3: PHPNW 2010 - Developing Easily Deployable PHP Applications

@2010 SugarCRM Inc. All rights reserved.

What I’ll cover

Writing portable codeEnabling configuration and customizationStrategies for testing and QAMaking your code perform well

7/22/2010 3

Page 4: PHPNW 2010 - Developing Easily Deployable PHP Applications

Writing portable code

7/22/2010 @2010 SugarCRM Inc. All rights reserved. 4

Source: http://www.flickr.com/photos/25339258@N05/2389910825/

Page 5: PHPNW 2010 - Developing Easily Deployable PHP Applications

Define your support matrix

Operating SystemAny Linux, UNIX, OS XWindows

Web ServerApache 1.3, 2.0, 2.2IIS 6/7 using FastCGI

DatabaseMySQL 5.0, 5.1SQL Server 2005, 2008Oracle 9i, 10g

PHP

5.2.x, 5.3.xSupport most common configurations options

mbstring.func_overload error_reporting = E_ALL

Require only the most mainline extensions, plus

Mbstrings ( i18n support )Imap ( mail support )Specific database extension ( mysql, mysqli, oci8, mssql, sqlsrv )

7/22/2010 @2010 SugarCRM Inc. All rights reserved. 5

Page 6: PHPNW 2010 - Developing Easily Deployable PHP Applications

Design code that works for these platforms

DB abstraction layer or ORMMake sure PHP features you are using are supported across support matrixAssume very little about the underlying system

Example: Treat file system as case-sensitive, and file writes are only in one area.

Detect what features the server has for you to use, have API to talk to them

Example: User cache ( APC, Memcache, Wincache, etc )

7/22/2010 @2010 SugarCRM Inc. All rights reserved. 6

Page 7: PHPNW 2010 - Developing Easily Deployable PHP Applications

Build and deploy!

We build all 3 editions of SugarCRM from 1 codebase

We add code tags around sections specific to a certain version.To test under each different edition, developers can run the build locally

We also can tag in or out features on a per edition basis.

7/22/2010 @2010 SugarCRM Inc. All rights reserved. 7

Source: http://www.flickr.com/photos/eastcapital/4554220770/

Page 8: PHPNW 2010 - Developing Easily Deployable PHP Applications

Enabling configuration and customization

7/22/2010 @2010 SugarCRM Inc. All rights reserved. 8

Source: http://www.flickr.com/photos/miskypig/400004362/

Page 9: PHPNW 2010 - Developing Easily Deployable PHP Applications

Making it simple yet powerful for end users

Expose configuration options thru multiple channels

Remember, not everyone has source access

Allow users to customize their UI interface easilyMake what should be simple, simple

7/22/2010 @2010 SugarCRM Inc. All rights reserved. 9

Page 10: PHPNW 2010 - Developing Easily Deployable PHP Applications

Making it simple yet powerful for developers

Create a safe place to make customizations

Avoid painful upgradesCreate an easy to use API

Well defined and supported.Don’t break it!

Create easy to use hooks for modifying / adding functionality

Examples from SugarCRM include:Metadata driven viewsLogic Hooks

Allow for internationalization and localization

7/22/2010 @2010 SugarCRM Inc. All rights reserved. 10

Page 11: PHPNW 2010 - Developing Easily Deployable PHP Applications

Strategies for testing and QA

7/22/2010 @2010 SugarCRM Inc. All rights reserved. 11

Source: http://www.flickr.com/photos/cglock/386033158/

Page 12: PHPNW 2010 - Developing Easily Deployable PHP Applications

Testing different configurations

Impossible for us to test every single permutation, so we use VM stacks instead

Windows Vista IIS-7 (FastCGI) PHP 5.2.8 MSSQL-2005 (PHP mssql driver) Windows Server 2003 IIS-6 (FastCGI) PHP 5.2.11 MSSQL-2005 (PHP mssql driver) CentOS 5 Apache-2.2.11 PHP 5.2.9 MySQL-5.1.33 Windows Server 2008 IIS-7 (FastCGI) PHP 5.3.1 MSSQL-2008 (Microsoft sqlsrv driver 1.1) Windows XP Apache-1.3.41 PHP 5.2.13 MySQL-5.0.83Oracle Enterprise Linux 5.1 Apache-2.0.63 PHP 5.3.2 ORCL-10g

We test both new installations and upgrade scenarios; even customer instances!

7/22/2010 @2010 SugarCRM Inc. All rights reserved. 12

Page 13: PHPNW 2010 - Developing Easily Deployable PHP Applications

Automated Testing Tools

Hudson (http://hudson-ci.org/) – Extensible CI ServerRunning on every checkin

PHP lint ( php –l ) – Syntax checking for PHP source filesPHPUnit (http://www.phpunit.de/) – Unit testing framework

Runs once a daySODA – functional testing framework that leverages Watir

– SodaMachine – GUI tool for building SODA testsJMeter (http://jakarta.apache.org/jmeter/) - tool for testing a website under high load

– MeterMaid – XML language to write JMeter tests in▪ SugarMMM (MeterMaid Maker) - utility to automate

writing MeterMaid tests for SugarCRM– TidBit – tool to make huge datasets for testing

All runs are against all flavors and all supported platform stacks

7/22/2010 @2010 SugarCRM Inc. All rights reserved. 13

Page 14: PHPNW 2010 - Developing Easily Deployable PHP Applications

Making your code perform well

7/22/2010 @2010 SugarCRM Inc. All rights reserved. 14

Source: http://www.flickr.com/photos/tech1987/501427718/

Page 15: PHPNW 2010 - Developing Easily Deployable PHP Applications

What we do to help performance

Try to do the basic stuffAvoid writing slow codeCaching, and lots of itCombine, minify, and version JS / CSS / imagesKeep SQL queries as simple as possible

Leave the rest to the Sys AdminProvide configuration options to turn off heavy featuresEnable the application to take advantage of it’s environment

Example: Using APC, memcache, Zend_Cache, wincache with little to no configuration

Provide best practices for various environments

7/22/2010 @2010 SugarCRM Inc. All rights reserved. 15

Page 16: PHPNW 2010 - Developing Easily Deployable PHP Applications

How we gauge performance

Formal testingUse Jmeter (http://jakarta.apache.org/jmeter/) on a load test cluster to test raw response speed.Instance analysis

Monitor web server logs to look for non-cached itemsTrack slow queries

Ad-hoc testingProfile PHP execution with XDebugUse Firebug to measure CSS / JS / image payload

7/22/2010 @2010 SugarCRM Inc. All rights reserved. 16

Page 17: PHPNW 2010 - Developing Easily Deployable PHP Applications

What are the lessons we have learned?

Define what you will support and to what extentWrite your code to be flexible to any environmentMake customizing, configuring, and extending your application not painful for users or developersTest across your support matrix, using automation as much as possibleFocus more on best practices and general performance, let admins handle it from there.

04/10/2023 @2010 SugarCRM Inc. All rights reserved. 17

Source: http://www.flickr.com/photos/dlanod/126386070/

Page 18: PHPNW 2010 - Developing Easily Deployable PHP Applications

About me and my company

John Mertichttp://jmertic.wordpress.comTwitter: @[email protected] ( Work )[email protected] ( PHP )Slides available on slideshare http://slidesha.re/9LX3Jp

SugarCRMhttp://www.sugarcrm.comWe’re hiring!Learn more about SugarCRM’s open source tools at http://developers.sugarcrm.com/opensource

7/22/2010 @2010 SugarCRM Inc. All rights reserved. 18

Buy my book!

Page 19: PHPNW 2010 - Developing Easily Deployable PHP Applications

Questions?

Please give feedback at http://joind.in/2059

7/22/2010 @2010 SugarCRM Inc. All rights reserved. 19