SlideShare a Scribd company logo
1 of 26
Download to read offline
Deployment
Beast
Zend/PHP Conference & Expo
San Jose, CA
10.20.2009
the
Taming
Wednesday, October 21, 2009
What is Deployment?
HERE THERE
The fun part is what happens in between...
- technology
- configuration
- coordination
- an increase in sanity
Wednesday, October 21, 2009
What’s included in Deployment?
- code testing
- building documentation
- checking permissions
- check coding standards
- updates/uninstall of components
- notifications
Wednesday, October 21, 2009
Thinking Environmentally
Development
Environment for application development (includes version control, unit testing, lint checks)
Quality Assurance/Testing
Environment for testing applications and ensuring all is functioning well
Staging
Environment immediately prior to deployment to production, checkout of current files
marked for "production"
Production
Environment for public consumption
Wednesday, October 21, 2009
Don’t Forget the Testing
Integration
Unit/other tests designed to identify potential errors with the communication
between pieces of functionality
Acceptance/System
Run "in browser" to validate functionality of the applications
Compatibility
Ensuring that the software will work with all platforms involved
Performance
Checking performance of the application on all sides
Security
Verifying that no security issues exist in the code for any stage in the process
Wednesday, October 21, 2009
Version Control Makes it Simple
CVS
Version control system, each file has its own version number, uses tags and
pseudo branches for code separation
Subversion
Version control system, repository has overall version number, uses tags/
branches for code separation
Git
Version control system, each checkout is a full repository in its own right,
allows for offline commits, updates/merges once connected
Wednesday, October 21, 2009
Pushin’ Data
Database migration tools
Version control system, each file has its own version number, uses tags and
pseudo branches for code separation
Keep it in version control too
Version control system, repository has overall version number, uses tags/
branches for code separation
Git
Version control system, each checkout is a full repository in its own right,
allows for offline commits, updates/merges once connected
Wednesday, October 21, 2009
Build it Out
Phing
PHP-based build tool, automates the build process for a site to be deployed.
XML-based build file for simple management (PHP)
Ant
Apache's build tool, designed for flexibility for multiple deployment types.
XML-based configuration files (Java)
Capistrano
Tool for automation of tasks on multiple servers (as opposed to just a local build).
Allows for rollbacks. (Ruby)
Wednesday, October 21, 2009
Document Your Code
phpDocumentor
Uses code comments to build documentation
Examples:
/**
* This library (MyLib) provides this bit of functionality
* @author Chris Cornutt <ccornutt@phpdeveloper.org>
* @package mylibs
*/
class MyLib { }
//------------------
/**
* This method takes in things and outputs others
* @param array $arr_in Input Array
* @param string $str_in Input String
* @return object $obj_out Output object
*/
public function myMethod($arr_in,$str_in,$obj_out){
return $obj_out;
}
Wiki software (like MediaWiki)
Used by Wikipedia
Document the “why”, not really the “how”
Easy to get out of control
Wednesday, October 21, 2009
Frontend Testing
Selenium
Firefox extension
Session recording for typing, clicks, etc
Three flavors: Selenium IDE, Selenium Remote Control, Seleium Grid
Multiple browser support (IE, Firefox, Safari, Chrome)
WebTests
Based on an Ant build process
Build XML-based repeatable tests
Worries more about the page than how its rendered
Output reports on test results
Wednesday, October 21, 2009
Continuous Integration
phpUnderControl (CruiseControl)
CruiseControl is Java-based, but build tools for Ant, Phing, Rake, etc
Plugins for git, svn, cvs
Output methods include emails, ftp, http, jabber, etc
pUc adds integration for things like PHPUnit, phpDocumentor, PHP_CodeSniffer
Chart output for unit test coverage, coding violations, timeline
Xinc (Native PHP)
Written in PHP5 with built-in SVN support
Stats output for build status, testing summary, duration
Installable via PEAR
Wednesday, October 21, 2009
Syntax Tools
Tidy
Extension for PHP (http://php.net/tidy)
Parsing XML and HTML
Can specify a custom configuration file
CleanRepair is your best friend
PHP_CodeSniffer
Reduces the code to “tokens” & checks location, surroundings to ensure compliance
Comes with default “sniffs” - PEAR, PHPCS, Zend, Squiz
Command line tool: phpcs
FILE: /path/to/code/myfile.php
--------------------------------------------------------------------------------
FOUND 5 ERROR(S) AND 1 WARNING(S) AFFECTING 5 LINE(S)
--------------------------------------------------------------------------------
2 | ERROR | Missing file doc comment
20 | ERROR | PHP keywords must be lowercase; expected "false" but found
| | "FALSE"
88 | ERROR | Line not indented correctly; expected 9 spaces but found 6
--------------------------------------------------------------------------------
Wednesday, October 21, 2009
Deployment Options
SVN (svn up)
ssh/scp
rsync
ftp/sftp
PEAR installer
phar packages
Other manual/automatic process
Wednesday, October 21, 2009
Enough Talk
It’s Time for Some Action
Wednesday, October 21, 2009
20090716-05
Overview
DEV
Unit
Test
Lint
Check
Build
Docs
Code
Standard
Subversion
PHPUnit
phpDocumentor
PHP’s lint
PHP_CodeSniffer
rsync
Phing / Ant
PROD
rsync
svn co
DB
Deploy PEAR Tar
Zip Report
Wednesday, October 21, 2009
Step 1 - Planning
What do we have right now?
What business processes/workflows need to be
considered?
Which technologies would we need to invest in?
What’s our release schedule?
Who’s going to run this thing?
Wednesday, October 21, 2009
Step 2 - Development
Single place to pull from
(You do use version control, right?)
Example:
Subversion environment with developer branches as well as QA and
PROD branches. PROD branch is “the point”.
PROD
DEV
QA
Wednesday, October 21, 2009
Step 3 - The Build
Determine the steps you’ll need
Think Easy
Server builds are good + Local build is even better
Example:
Phing configuration that includes an anonymous checkout of the latest from the repository,
a run of all unit tests for the project, generate the docs via phpDocumentor, check the syntax of
all files and run an rsync script to push it out live.
Wednesday, October 21, 2009
Step 3 - The Build (Phing)
<?xml version=”1.0”>
<project name=”deploy_me” default=”main”>
<property name=”version” value=”1.0” />
<target name=”unittest”>
<phpunit>
<batchtest>
<fileset dir=”/www/mysite/tests”>
<include name=”**/*Test*.php” />
</fileset>
</batchtest>
</phpunit>
</target>
<target name=”phpdoc” depends=”unittest”>
<phpdoc title=”MySite Documentation” destdir=”/www/mysite/docs” output=”HTML:Smarty:PHP”>
<fileset dir=”/www/mysite/docroot”>
<include name=”**/*.php” />
</fileset>
</phpdoc>
</target>
<target name=”lintme” depends=”phpdoc”>
<phplint>
<fileset dir=”/www/mysite/docroot”>
<include name=”**/*.php” />
</fileset>
</phplint>
</target>
<target name=”standardsplz” depends=”lintme”>
<phpcodesniffer standard=”PEAR” format=”summary” file=”/www/mysite/docroot”
allowedFileExtensions=”php php5 inc” />
</target>
<target name=”main” depends=”standardsplz”>
</target>
</project>
Wednesday, October 21, 2009
Step 3 - The Build (Ant)
<?xml version=”1.0”>
<project name="deploy_me" default="main" basedir=".">
<property name="version" value="1.0"/>
<target name="unittest">
<exec dir="${basedir}/source" executable="phpunit" failonerror="true">
<arg line="--log-xml ${basedir}/build/logs/testlog.xml"/>
</exec>
</target>
<target name="phpdoc" depends="unittest">
<exec executable="phpdoc" dir="${basedir}/source">
<arg line="-ct type -ue on -t ${basedir}/build/api -tb /PATH/TO/YOUR/PHPUC/DATA/phpdoc -o
HTML:Phpuc:phpuc -d src/"/>
</exec>
</target>
<target name="lintme" depends="phpdoc">
</target>
<target name="standardsplz" depends="lintme">
<exec executable="phpcs" dir="${basedir}/source" output="${basedir}/build/logs/checkstyle.xml">
<arg line="--report=checkstyle --standard=PEAR --ignore=src/autoload src/"/>
</exec>
</target>
<target name="main" depends="standardsplz">
</target>
</project>
Wednesday, October 21, 2009
Step 4 - The Push
Where’s “here” and where’s “there”?
And what’s in between that could cause issues...
Pick the right tools & process for you
Things to consider: network config, what’s already in use (piggyback on a protocol?)
Ready...Set...Wait
Do you have everything you need? Is the staging environment ready?
Wednesday, October 21, 2009
Step 4 - The Push (cont.)
2%
2%
4%
4%
4%
5%
11%
21%
47%
SVN FTP/SFTP
RSYNC Capistrano
SSH/SCP Ant
Automatic Cut & Paste
Manual
Wednesday, October 21, 2009
Step 5 - The Aftermath
Clean up your mess, young man
This is where post-push belongs, wrap it all up
Make sure dev is ready to do it all again
Deployment should be simple and automatic
Giving the “All Clear”
Be sure to run your tests to ensure that all is happy in production.
Wednesday, October 21, 2009
That’s All, Right?
Murphy has this law...
Perfect deployment is a myth
Must be able to roll back
A similar “single-button” solution
Most tools can help
Included rollback feature, or just the ability to pull the previous version
Easier with code, harder with data
Database rollbacks can be tricky
Wednesday, October 21, 2009
The Point of it All
Like flipping a switch, a good build should make
deploying your website a simple task, no matter
the complexity.
It should remove the burden of repetitive tasks
from developers and make lives easier.
Wednesday, October 21, 2009
Questions,
Comments,
Suggestions?
ccornutt@phpdeveloper.org
@enygma
http://blog.phpdeveloper.org
http://joind.in/talk/view/902
Wednesday, October 21, 2009

More Related Content

What's hot

02 - Build and Deployment Management
02 - Build and Deployment Management02 - Build and Deployment Management
02 - Build and Deployment Management
Sergii Shmarkatiuk
 
Sybsc cs sem 3 core java
Sybsc cs sem 3 core javaSybsc cs sem 3 core java
Sybsc cs sem 3 core java
WE-IT TUTORIALS
 

What's hot (18)

Dynamic Overriding
Dynamic OverridingDynamic Overriding
Dynamic Overriding
 
02 - Build and Deployment Management
02 - Build and Deployment Management02 - Build and Deployment Management
02 - Build and Deployment Management
 
Inside Android's Dalvik VM - NEJUG Nov 2011
Inside Android's Dalvik VM - NEJUG Nov 2011Inside Android's Dalvik VM - NEJUG Nov 2011
Inside Android's Dalvik VM - NEJUG Nov 2011
 
Win7 Novinky
Win7 NovinkyWin7 Novinky
Win7 Novinky
 
Accelerated Android Development with Linaro
Accelerated Android Development with LinaroAccelerated Android Development with Linaro
Accelerated Android Development with Linaro
 
Skype testing overview
Skype testing overviewSkype testing overview
Skype testing overview
 
Program development tools
Program development toolsProgram development tools
Program development tools
 
02.egovFrame Development Environment workshop I
02.egovFrame  Development Environment workshop I02.egovFrame  Development Environment workshop I
02.egovFrame Development Environment workshop I
 
02. egovFrame Development Environment workshop II en(nexus&ci)
02. egovFrame Development Environment workshop II en(nexus&ci)02. egovFrame Development Environment workshop II en(nexus&ci)
02. egovFrame Development Environment workshop II en(nexus&ci)
 
What Your Jvm Has Been Trying To Tell You
What Your Jvm Has Been Trying To Tell YouWhat Your Jvm Has Been Trying To Tell You
What Your Jvm Has Been Trying To Tell You
 
Sybsc cs sem 3 core java
Sybsc cs sem 3 core javaSybsc cs sem 3 core java
Sybsc cs sem 3 core java
 
Os Lattner
Os LattnerOs Lattner
Os Lattner
 
.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques
 
Guides To Analyzing WebKit Performance
Guides To Analyzing WebKit PerformanceGuides To Analyzing WebKit Performance
Guides To Analyzing WebKit Performance
 
LWF 101 for Open Hack Day
LWF 101 for Open Hack DayLWF 101 for Open Hack Day
LWF 101 for Open Hack Day
 
Qualipso factory
Qualipso factoryQualipso factory
Qualipso factory
 
05 - Merge Management
05 - Merge Management05 - Merge Management
05 - Merge Management
 
Learn C Programming Language by Using GDB
Learn C Programming Language by Using GDBLearn C Programming Language by Using GDB
Learn C Programming Language by Using GDB
 

Viewers also liked

Roniere Santos DireçãO De Arte Pedotti
Roniere Santos DireçãO De Arte PedottiRoniere Santos DireçãO De Arte Pedotti
Roniere Santos DireçãO De Arte Pedotti
Portfoliopp
 
Dr. GVR Sastry - Speaker Profile(1) (1)
Dr. GVR Sastry - Speaker Profile(1) (1)Dr. GVR Sastry - Speaker Profile(1) (1)
Dr. GVR Sastry - Speaker Profile(1) (1)
Prof .Dr. GVR SHASTRI
 
Lessons From Cahokia1
Lessons From Cahokia1Lessons From Cahokia1
Lessons From Cahokia1
ansmith
 

Viewers also liked (9)

Caching for Cash, part 4 DPC 2009
Caching for Cash, part 4 DPC 2009Caching for Cash, part 4 DPC 2009
Caching for Cash, part 4 DPC 2009
 
Zend Server: A Guided Tour
Zend Server: A Guided TourZend Server: A Guided Tour
Zend Server: A Guided Tour
 
Kewelta´s Portal New Design
Kewelta´s Portal New DesignKewelta´s Portal New Design
Kewelta´s Portal New Design
 
Tiery Eyed
Tiery EyedTiery Eyed
Tiery Eyed
 
Planning for Synchronization with Browser-Local Databases
Planning for Synchronization with Browser-Local DatabasesPlanning for Synchronization with Browser-Local Databases
Planning for Synchronization with Browser-Local Databases
 
Roniere Santos DireçãO De Arte Pedotti
Roniere Santos DireçãO De Arte PedottiRoniere Santos DireçãO De Arte Pedotti
Roniere Santos DireçãO De Arte Pedotti
 
Dr. GVR Sastry - Speaker Profile(1) (1)
Dr. GVR Sastry - Speaker Profile(1) (1)Dr. GVR Sastry - Speaker Profile(1) (1)
Dr. GVR Sastry - Speaker Profile(1) (1)
 
Lessons From Cahokia1
Lessons From Cahokia1Lessons From Cahokia1
Lessons From Cahokia1
 
Frontend Caching - The "new" frontier
Frontend Caching - The "new" frontierFrontend Caching - The "new" frontier
Frontend Caching - The "new" frontier
 

Taming the Deployment Beast

  • 1. Deployment Beast Zend/PHP Conference & Expo San Jose, CA 10.20.2009 the Taming Wednesday, October 21, 2009
  • 2. What is Deployment? HERE THERE The fun part is what happens in between... - technology - configuration - coordination - an increase in sanity Wednesday, October 21, 2009
  • 3. What’s included in Deployment? - code testing - building documentation - checking permissions - check coding standards - updates/uninstall of components - notifications Wednesday, October 21, 2009
  • 4. Thinking Environmentally Development Environment for application development (includes version control, unit testing, lint checks) Quality Assurance/Testing Environment for testing applications and ensuring all is functioning well Staging Environment immediately prior to deployment to production, checkout of current files marked for "production" Production Environment for public consumption Wednesday, October 21, 2009
  • 5. Don’t Forget the Testing Integration Unit/other tests designed to identify potential errors with the communication between pieces of functionality Acceptance/System Run "in browser" to validate functionality of the applications Compatibility Ensuring that the software will work with all platforms involved Performance Checking performance of the application on all sides Security Verifying that no security issues exist in the code for any stage in the process Wednesday, October 21, 2009
  • 6. Version Control Makes it Simple CVS Version control system, each file has its own version number, uses tags and pseudo branches for code separation Subversion Version control system, repository has overall version number, uses tags/ branches for code separation Git Version control system, each checkout is a full repository in its own right, allows for offline commits, updates/merges once connected Wednesday, October 21, 2009
  • 7. Pushin’ Data Database migration tools Version control system, each file has its own version number, uses tags and pseudo branches for code separation Keep it in version control too Version control system, repository has overall version number, uses tags/ branches for code separation Git Version control system, each checkout is a full repository in its own right, allows for offline commits, updates/merges once connected Wednesday, October 21, 2009
  • 8. Build it Out Phing PHP-based build tool, automates the build process for a site to be deployed. XML-based build file for simple management (PHP) Ant Apache's build tool, designed for flexibility for multiple deployment types. XML-based configuration files (Java) Capistrano Tool for automation of tasks on multiple servers (as opposed to just a local build). Allows for rollbacks. (Ruby) Wednesday, October 21, 2009
  • 9. Document Your Code phpDocumentor Uses code comments to build documentation Examples: /** * This library (MyLib) provides this bit of functionality * @author Chris Cornutt <ccornutt@phpdeveloper.org> * @package mylibs */ class MyLib { } //------------------ /** * This method takes in things and outputs others * @param array $arr_in Input Array * @param string $str_in Input String * @return object $obj_out Output object */ public function myMethod($arr_in,$str_in,$obj_out){ return $obj_out; } Wiki software (like MediaWiki) Used by Wikipedia Document the “why”, not really the “how” Easy to get out of control Wednesday, October 21, 2009
  • 10. Frontend Testing Selenium Firefox extension Session recording for typing, clicks, etc Three flavors: Selenium IDE, Selenium Remote Control, Seleium Grid Multiple browser support (IE, Firefox, Safari, Chrome) WebTests Based on an Ant build process Build XML-based repeatable tests Worries more about the page than how its rendered Output reports on test results Wednesday, October 21, 2009
  • 11. Continuous Integration phpUnderControl (CruiseControl) CruiseControl is Java-based, but build tools for Ant, Phing, Rake, etc Plugins for git, svn, cvs Output methods include emails, ftp, http, jabber, etc pUc adds integration for things like PHPUnit, phpDocumentor, PHP_CodeSniffer Chart output for unit test coverage, coding violations, timeline Xinc (Native PHP) Written in PHP5 with built-in SVN support Stats output for build status, testing summary, duration Installable via PEAR Wednesday, October 21, 2009
  • 12. Syntax Tools Tidy Extension for PHP (http://php.net/tidy) Parsing XML and HTML Can specify a custom configuration file CleanRepair is your best friend PHP_CodeSniffer Reduces the code to “tokens” & checks location, surroundings to ensure compliance Comes with default “sniffs” - PEAR, PHPCS, Zend, Squiz Command line tool: phpcs FILE: /path/to/code/myfile.php -------------------------------------------------------------------------------- FOUND 5 ERROR(S) AND 1 WARNING(S) AFFECTING 5 LINE(S) -------------------------------------------------------------------------------- 2 | ERROR | Missing file doc comment 20 | ERROR | PHP keywords must be lowercase; expected "false" but found | | "FALSE" 88 | ERROR | Line not indented correctly; expected 9 spaces but found 6 -------------------------------------------------------------------------------- Wednesday, October 21, 2009
  • 13. Deployment Options SVN (svn up) ssh/scp rsync ftp/sftp PEAR installer phar packages Other manual/automatic process Wednesday, October 21, 2009
  • 14. Enough Talk It’s Time for Some Action Wednesday, October 21, 2009
  • 16. Step 1 - Planning What do we have right now? What business processes/workflows need to be considered? Which technologies would we need to invest in? What’s our release schedule? Who’s going to run this thing? Wednesday, October 21, 2009
  • 17. Step 2 - Development Single place to pull from (You do use version control, right?) Example: Subversion environment with developer branches as well as QA and PROD branches. PROD branch is “the point”. PROD DEV QA Wednesday, October 21, 2009
  • 18. Step 3 - The Build Determine the steps you’ll need Think Easy Server builds are good + Local build is even better Example: Phing configuration that includes an anonymous checkout of the latest from the repository, a run of all unit tests for the project, generate the docs via phpDocumentor, check the syntax of all files and run an rsync script to push it out live. Wednesday, October 21, 2009
  • 19. Step 3 - The Build (Phing) <?xml version=”1.0”> <project name=”deploy_me” default=”main”> <property name=”version” value=”1.0” /> <target name=”unittest”> <phpunit> <batchtest> <fileset dir=”/www/mysite/tests”> <include name=”**/*Test*.php” /> </fileset> </batchtest> </phpunit> </target> <target name=”phpdoc” depends=”unittest”> <phpdoc title=”MySite Documentation” destdir=”/www/mysite/docs” output=”HTML:Smarty:PHP”> <fileset dir=”/www/mysite/docroot”> <include name=”**/*.php” /> </fileset> </phpdoc> </target> <target name=”lintme” depends=”phpdoc”> <phplint> <fileset dir=”/www/mysite/docroot”> <include name=”**/*.php” /> </fileset> </phplint> </target> <target name=”standardsplz” depends=”lintme”> <phpcodesniffer standard=”PEAR” format=”summary” file=”/www/mysite/docroot” allowedFileExtensions=”php php5 inc” /> </target> <target name=”main” depends=”standardsplz”> </target> </project> Wednesday, October 21, 2009
  • 20. Step 3 - The Build (Ant) <?xml version=”1.0”> <project name="deploy_me" default="main" basedir="."> <property name="version" value="1.0"/> <target name="unittest"> <exec dir="${basedir}/source" executable="phpunit" failonerror="true"> <arg line="--log-xml ${basedir}/build/logs/testlog.xml"/> </exec> </target> <target name="phpdoc" depends="unittest"> <exec executable="phpdoc" dir="${basedir}/source"> <arg line="-ct type -ue on -t ${basedir}/build/api -tb /PATH/TO/YOUR/PHPUC/DATA/phpdoc -o HTML:Phpuc:phpuc -d src/"/> </exec> </target> <target name="lintme" depends="phpdoc"> </target> <target name="standardsplz" depends="lintme"> <exec executable="phpcs" dir="${basedir}/source" output="${basedir}/build/logs/checkstyle.xml"> <arg line="--report=checkstyle --standard=PEAR --ignore=src/autoload src/"/> </exec> </target> <target name="main" depends="standardsplz"> </target> </project> Wednesday, October 21, 2009
  • 21. Step 4 - The Push Where’s “here” and where’s “there”? And what’s in between that could cause issues... Pick the right tools & process for you Things to consider: network config, what’s already in use (piggyback on a protocol?) Ready...Set...Wait Do you have everything you need? Is the staging environment ready? Wednesday, October 21, 2009
  • 22. Step 4 - The Push (cont.) 2% 2% 4% 4% 4% 5% 11% 21% 47% SVN FTP/SFTP RSYNC Capistrano SSH/SCP Ant Automatic Cut & Paste Manual Wednesday, October 21, 2009
  • 23. Step 5 - The Aftermath Clean up your mess, young man This is where post-push belongs, wrap it all up Make sure dev is ready to do it all again Deployment should be simple and automatic Giving the “All Clear” Be sure to run your tests to ensure that all is happy in production. Wednesday, October 21, 2009
  • 24. That’s All, Right? Murphy has this law... Perfect deployment is a myth Must be able to roll back A similar “single-button” solution Most tools can help Included rollback feature, or just the ability to pull the previous version Easier with code, harder with data Database rollbacks can be tricky Wednesday, October 21, 2009
  • 25. The Point of it All Like flipping a switch, a good build should make deploying your website a simple task, no matter the complexity. It should remove the burden of repetitive tasks from developers and make lives easier. Wednesday, October 21, 2009