Automated Deployment With Phing<br />Or: How I Will Replace You With A Very Small Shell Script<br />ZendCon &apos;09<br />...
Who<br />Daniel Cousineau<br />Senior Software Applications Developer<br />	Texas A&M University<br />	Division of Student...
The Problem<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />3<br />
Human beings make mistakes<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />4<br />
We aren’t as accurate each repetition<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />5...
Machines don’t have this problem<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />6<br />
They do the same thing every time (supposedly)<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousine...
At Any Given Time<br />New Code<br />New Configuration<br />New Database Schema<br />New Static Files<br />ZendCon &apos;0...
A Lot To Remember<br />Did you remember to upload ALL new files?<br />Did you remember to update your DB?<br />Did you rem...
Even Worse<br />Did you clear your caches?<br />Did you delete that old file/plugin?<br />In the upload process, was your ...
The Solution<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />11<br />
Automation!<br />Build scripts!<br />We are programmers after all…<br />ZendCon &apos;09<br />Automated Deployment With Ph...
ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />13<br />Don’t Do More Work Than You Have To!...
ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />14<br />Work Hard At Being Lazy!<br />
What is Automation?<br />Automated deployment means a single command<br />Locks your live site<br />Uploads changed files<...
Why Do We Automate?<br />Deployment is tricky<br />Repetition degrades quality<br />She sells sea shells by the sea shore<...
When Is Automation Used?<br />All the time!<br />Staging<br />Live<br />Probably best to use it on your dev box too!<br />...
The Basics<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />18<br />
Tools of the Trade<br />Build System<br />Phing<br />Apache ANT<br />Capastrano<br />Plain PHP or BASH or BAT Files<br />F...
Phing Philosophy<br />Build scripts contains &quot;Targets&quot;<br />Targets should be small and specialized.<br />Exampl...
Phing Philosophy<br />Targets can have dependencies<br />Target &quot;live&quot; can depend on clean, copy, and migrate<br...
Installing Phing<br />pear channel-discover pear.phing.info<br />pear install phing/Phing<br />Want all the little depende...
Running Phing<br />$&gt; phing –v<br />Lists Phing version<br />Phing expects to find a file &quot;build.xml&quot; in the ...
Syntax<br />XML<br />If you don’t already know it, you have bigger problems<br />Variables<br />${variablename}<br />Conve...
Basic Conventions<br />build.xml<br />Central repository of your top-level tasks<br />build-*.xml<br />Can be included int...
Basic build.xml<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />26<br />&lt;?xml versio...
Basic build.properties<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />27<br />source.d...
File Transfer<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />28<br />
Techniques<br />Built in Phing Copy Task<br />Cross Platform<br />Slow<br />Not over network<br />Version Control Checkout...
Pitfalls<br />Cleanup Deleted Source Files<br />Usually only a problem when you have * include patterns<br />ZendCon &apos...
Pitfalls<br />User created files are a HUGE pitfall<br />/htdocs/images/upload<br />Sync programs usually will delete cont...
Executing External Tools<br />Nearly all file transfer tools will be external commands<br />For this we need the Exec task...
Rsync<br />So many different options you’re best off finding your own tutorials or reading MAN pages<br />rsync -aCvz<br /...
Rsync Options Of Note<br />-a	archive-mode<br />Recursive copy, preserve everything, etc.<br />-C	cvs-exclude<br />Ignore ...
Xcopy<br />Best when your live deployment process involves copying to a network share on Windows machines<br />xcopy<br />...
Xcopy Options Of Note<br />/d<br />Update only those files that are different (timestamps)<br />/i<br />Creates target dir...
Xcopy Exclude File Example<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />37<br />	mp<...
Configuration Management<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />38<br />
Techniques<br />Check incoming domain<br />www.domain.com means load production configuration<br />localhost/domain.com me...
Check Incoming Domain	<br />Pros<br />No chance for error<br />Cons<br />Detection is a weak link<br />Especially when dev...
Check for an Environment File<br />Pros<br />Consistent regardless of Server or OS changes<br />Easy to repair<br />Quick ...
Copy Over During Deployment<br />Pros<br />Images and CSS now manageable<br />Reduce redundancy<br />Simple to repurpose r...
Which one to choose?<br />Depends on your application architecture<br />Depends on your environment<br />You’ll know what’...
Database Migration<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />44<br />
Database Deployment Philosophy<br />“Versions” often referred to as “Deltas”<br />Each Delta has an UP and a DOWN script<b...
DBDeploy Philosophy<br />Each delta is 2 native SQL scripts<br />Separated by --//@undo<br />Database version is stored in...
DBDeploy Under The Hood<br />Connect to the database, read from changelog table, get the most current revision installed<b...
Installing DBDeploy<br />Is Phing already installed? Great! So is DBDeploy…<br />Create the changelog table<br />Track the...
Basic Delta: 01_init.sql<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />49<br />--//  ...
Run Migration<br />First add a task to your Phing build file<br />ZendCon &apos;09<br />Automated Deployment With Phing - ...
Run Migration<br />Generate the SQL migration file<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cou...
Run Migration<br />Execute the SQL script<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br...
Pitfalls<br />Make sure you have a good CLI app for loading a SQL file<br />/usr/bin/mysql<br />mysql.exe<br />Build scrip...
Doctrine Database Migrations<br />Integrated into the Doctrine CLI tool<br />./doctrine migrate<br />Same philosophies<br ...
Other Database Migration Tools<br />http://www.liquibase.org/<br />ZendCon &apos;09<br />Automated Deployment With Phing -...
Closing Thoughts<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />56<br />
Further Resources<br />The people around you<br />More people than you know automate their deployment<br />There are many,...
Further Resources<br />Blogs<br />http://phpdeveloper.org<br />Documentation<br />http://phing.info<br />http://dbdeploy.c...
Questions?<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />59<br />
http://joind.in/937<br />
Upcoming SlideShare
Loading in...5
×

Automated Deployment With Phing

14,545

Published on

Website deployment is a tedious and intricate task that lends itself to human error (oops, did I forget to update the DB schema?). Using Phing in conjunction with deployment techniques can greatly reduce the risk of human error and increase productivity. The presentation will cover using Phing to sync files, run tasks, migrate databases, target configuration, and other deployment techniques.

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

No Downloads
Views
Total Views
14,545
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
304
Comments
0
Likes
35
Embeds 0
No embeds

No notes for slide
  • Image Credit: http://www.acadweb.wwu.edu/dbrunner/
  • Image Credit: http://commons.wikimedia.org/wiki/File:Archery_target.jpg
  • Image Credit: http://www.drmcninja.com/junk/highfiveshirt.png
  • Automated Deployment With Phing

    1. 1. Automated Deployment With Phing<br />Or: How I Will Replace You With A Very Small Shell Script<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />1<br />
    2. 2. Who<br />Daniel Cousineau<br />Senior Software Applications Developer<br /> Texas A&M University<br /> Division of Student Affairs<br /> Department of IT<br />http://www.toosweettobesour.com/<br />@dcousineau<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />2<br />
    3. 3. The Problem<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />3<br />
    4. 4. Human beings make mistakes<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />4<br />
    5. 5. We aren’t as accurate each repetition<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />5<br />
    6. 6. Machines don’t have this problem<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />6<br />
    7. 7. They do the same thing every time (supposedly)<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />7<br />
    8. 8. At Any Given Time<br />New Code<br />New Configuration<br />New Database Schema<br />New Static Files<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />8<br />
    9. 9. A Lot To Remember<br />Did you remember to upload ALL new files?<br />Did you remember to update your DB?<br />Did you remember to correct your config?<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />9<br />
    10. 10. Even Worse<br />Did you clear your caches?<br />Did you delete that old file/plugin?<br />In the upload process, was your configuration overwritten?<br />Did you upload ALL the changed files?<br />When did you last upload?<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />10<br />
    11. 11. The Solution<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />11<br />
    12. 12. Automation!<br />Build scripts!<br />We are programmers after all…<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />12<br />
    13. 13. ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />13<br />Don’t Do More Work Than You Have To!<br />
    14. 14. ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />14<br />Work Hard At Being Lazy!<br />
    15. 15. What is Automation?<br />Automated deployment means a single command<br />Locks your live site<br />Uploads changed files<br />Clears caches and temporary files<br />Updates the database schema<br />Runs other cron tasks<br />Unlocks your live site<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />15<br />
    16. 16. Why Do We Automate?<br />Deployment is tricky<br />Repetition degrades quality<br />She sells sea shells by the sea shore<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />16<br />
    17. 17. When Is Automation Used?<br />All the time!<br />Staging<br />Live<br />Probably best to use it on your dev box too!<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />17<br />
    18. 18. The Basics<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />18<br />
    19. 19. Tools of the Trade<br />Build System<br />Phing<br />Apache ANT<br />Capastrano<br />Plain PHP or BASH or BAT Files<br />File Transfer<br />Rsync (*NIX Environments)<br />Xcopy (Windows Environments)<br />Configuration Management<br />Database Migration<br />DBDeploy<br />Doctrine<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />19<br />
    20. 20. Phing Philosophy<br />Build scripts contains &quot;Targets&quot;<br />Targets should be small and specialized.<br />Example Targets:<br />clean<br />Clear temporary and cached files<br />copy<br />Copy files to their intended destination<br />migrate<br />Upgrade the database schema<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />20<br />
    21. 21. Phing Philosophy<br />Targets can have dependencies<br />Target &quot;live&quot; can depend on clean, copy, and migrate<br />Meaning, when we run the &quot;live&quot; target, it first runs clean, copy, then migrate<br />And any tasks they depend on<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />21<br />
    22. 22. Installing Phing<br />pear channel-discover pear.phing.info<br />pear install phing/Phing<br />Want all the little dependencies?<br />pear config-set preferred_state alpha<br />pear install –alldepsphing/Phing<br />pear config-set preferred_state stable<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />22<br />
    23. 23. Running Phing<br />$&gt; phing –v<br />Lists Phing version<br />Phing expects to find a file &quot;build.xml&quot; in the current directory<br />build.xml defines the targets<br />You can use the &quot;-f &lt;filename&gt;&quot; flag to specify an alternate build file like<br />$&gt; phing -f build-live.xml<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />23<br />
    24. 24. Syntax<br />XML<br />If you don’t already know it, you have bigger problems<br />Variables<br />${variablename}<br />Conventions<br />Psuedo-Namespaces using periods<br />${namespace.variable.name}<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />24<br />
    25. 25. Basic Conventions<br />build.xml<br />Central repository of your top-level tasks<br />build-*.xml<br />Can be included into build.xml. <br />Usually for grouping by target (dev, staging, live) or task (migrate, test, etc.)<br />build.properties<br />Technically an INI file that contains variables to be included by build files.<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />25<br />
    26. 26. Basic build.xml<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />26<br />&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br />&lt;project name=&quot;ZendCon&quot; default=&quot;default&quot; basedir=&quot;.&quot;&gt;<br /> &lt;property file=&quot;build.properties&quot; /&gt;<br /> &lt;target name=&quot;default&quot;&gt;<br />    &lt;echo message=&quot;Howdy World!&quot; /&gt;<br /> &lt;/target&gt;       <br />&lt;/project&gt;<br />
    27. 27. Basic build.properties<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />27<br />source.directory = /src<br />## Database Configuration<br />db.user = username<br />db.pass = password<br />db.host = localhost<br />db.name = database<br />
    28. 28. File Transfer<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />28<br />
    29. 29. Techniques<br />Built in Phing Copy Task<br />Cross Platform<br />Slow<br />Not over network<br />Version Control Checkout/Update<br />Syncs deleted files<br />User created files usually ignored<br />Rsync<br />Great for *NIX environments.<br />Almost guaranteed to be installed on<br />Linux, BSD, Mac OSX<br />Can be installed on Windows<br />Xcopy<br />Good for Windows environments<br />Faster than Phing Copy<br />Not over network<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />29<br />
    30. 30. Pitfalls<br />Cleanup Deleted Source Files<br />Usually only a problem when you have * include patterns<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />30<br />
    31. 31. Pitfalls<br />User created files are a HUGE pitfall<br />/htdocs/images/upload<br />Sync programs usually will delete content your deployment machine doesn’t have<br />What if user upload are mixed in with files you want to manage?<br />Solutions<br />Keep user created content completely separated. The further up the file tree and consolidated the better.<br />Separate static file server, Amazon S3, or other style CDNs<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />31<br />
    32. 32. Executing External Tools<br />Nearly all file transfer tools will be external commands<br />For this we need the Exec task<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />32<br />&lt;exec command=&quot;cp file1 file2&quot; /&gt;<br />
    33. 33. Rsync<br />So many different options you’re best off finding your own tutorials or reading MAN pages<br />rsync -aCvz<br /> -e &apos;ssh -i /path/to/ssh-key&apos;<br /> ${project.basedir}/src<br />user@domain: ${staging.deployment.directory}/<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />33<br />
    34. 34. Rsync Options Of Note<br />-a archive-mode<br />Recursive copy, preserve everything, etc.<br />-C cvs-exclude<br />Ignore .cvs, .svn, and other version control artifacts<br />-v verbose<br />Know EXACTLY what’s going on<br />-z compress<br />Compress information transmitted<br />-e alternative remote shell<br />Use a custom SSH command (namely use key-pair)<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />34<br />
    35. 35. Xcopy<br />Best when your live deployment process involves copying to a network share on Windows machines<br />xcopy<br /> ${project.basedir}${source.directory}*<br /> ${staging.deployment.directory}<br /> /D /I /Y /S /E<br /> /Exclude:${project.basedir}staging.deployment.exclude<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />35<br />
    36. 36. Xcopy Options Of Note<br />/d<br />Update only those files that are different (timestamps)<br />/i<br />Creates target directories if they don’t exist<br />/y<br />Do not prompt<br />/s<br />Copy all directories and sub-directories…<br />/e<br />…Even if the directories are empty <br />/exclude<br />Exclude files based on glob patterns<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />36<br />
    37. 37. Xcopy Exclude File Example<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />37<br /> mp<br />uploads<br />
    38. 38. Configuration Management<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />38<br />
    39. 39. Techniques<br />Check incoming domain<br />www.domain.com means load production configuration<br />localhost/domain.com means load development configuration<br />Check for an environment file<br />Contents of DOCUMENT_ROOT/.env determine configuration<br />Copy over during deployment<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />39<br />
    40. 40. Check Incoming Domain <br />Pros<br />No chance for error<br />Cons<br />Detection is a weak link<br />Especially when development, staging, and live have different web servers (e.g. Apache to IIS)<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />40<br />
    41. 41. Check for an Environment File<br />Pros<br />Consistent regardless of Server or OS changes<br />Easy to repair<br />Quick FTP or SSH<br />Easy Testing<br />Just swap file contents<br />Cons<br />Forget to copy changes?<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />41<br />
    42. 42. Copy Over During Deployment<br />Pros<br />Images and CSS now manageable<br />Reduce redundancy<br />Simple to repurpose regular push command<br />Cons<br />Difficult to manage<br />Forget to copy changes?<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />42<br />
    43. 43. Which one to choose?<br />Depends on your application architecture<br />Depends on your environment<br />You’ll know what’s best for your project<br />I use a combination of Environment File and Copy Over During Deployment<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />43<br />
    44. 44. Database Migration<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />44<br />
    45. 45. Database Deployment Philosophy<br />“Versions” often referred to as “Deltas”<br />Each Delta has an UP and a DOWN script<br />UP makes the changes<br />DOWN reverts the changes<br />Each change should be a non-destructive schema change<br />Unless of course you need data alteration<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />45<br />
    46. 46. DBDeploy Philosophy<br />Each delta is 2 native SQL scripts<br />Separated by --//@undo<br />Database version is stored in a special table<br />Version X was applied at TIMESTAMP…<br />Beware corruption!<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />46<br />
    47. 47. DBDeploy Under The Hood<br />Connect to the database, read from changelog table, get the most current revision installed<br />Retrieve all delta files newer that the current revision<br />Revision numbers are based off of alphabetic sorting, name your files accordingly<br />Pull all the “UP” changes and concatenate them to a migration script<br />Up to YOU to run the migration script<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />47<br />
    48. 48. Installing DBDeploy<br />Is Phing already installed? Great! So is DBDeploy…<br />Create the changelog table<br />Track the current version of your DB<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />48<br />CREATE TABLE changelog (  <br />  change_number BIGINT NOT NULL,  <br />  delta_set VARCHAR(10) NOT NULL,  <br />  start_dt TIMESTAMP NOT NULL,  <br />  complete_dt TIMESTAMP NULL,  <br />  applied_by VARCHAR(100) NOT NULL,  <br />  description VARCHAR(500) NOT NULL  <br />);<br />ALTER TABLE changelog<br /> ADD CONSTRAINT Pkchangelog PRIMARY KEY (change_number, delta_set);<br />
    49. 49. Basic Delta: 01_init.sql<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />49<br />--//  <br />CREATE TABLE IF NOT EXISTS `users` (  <br />  `id` int(10) unsigned NOT NULL auto_increment,  <br />  `handle` varchar(25) NOT NULL default &apos;&apos;,  <br />  PRIMARY KEY  (`id`),  <br />  UNIQUE KEY `users_handle_index` (`handle`)  <br />) ENGINE=InnoDB  DEFAULT;  <br />--//@UNDO    <br />DROP TABLE IF EXISTS `users`;  <br />--//<br />
    50. 50. Run Migration<br />First add a task to your Phing build file<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />50<br />&lt;target name=&quot;migrate&quot;&gt;<br />&lt;/target&gt;<br />
    51. 51. Run Migration<br />Generate the SQL migration file<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />51<br />&lt;target name=&quot;migrate&quot;&gt;<br /> &lt;dbdeploy<br />url=&quot;mysql:host=${db.host};dbname=${db.name}&quot;<br />userid=&quot;${db.user}&quot;<br /> password=&quot;${db.pass}&quot;<br /> dir=&quot;${project.basedir}/db/deltas&quot;<br />outputfile=&quot;${project.basedir}/up.sql&quot;<br />undooutputfile=&quot;${project.basedir}/down.sql&quot;<br /> /&gt;<br />&lt;/target&gt;<br />
    52. 52. Run Migration<br />Execute the SQL script<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />52<br />&lt;target name=&quot;migrate&quot;&gt;<br /> &lt;dbdeploy<br />url=&quot;mysql:host=${db.host};dbname=${db.name}&quot;<br />userid=&quot;${db.user}&quot;<br /> password=&quot;${db.pass}&quot;<br /> dir=&quot;${project.basedir}/db/deltas&quot;<br />outputfile=&quot;${project.basedir}/up.sql&quot;<br />undooutputfile=&quot;${project.basedir}/down.sql&quot;<br /> /&gt;<br /> &lt;exec<br /> command=&quot;/usr/bin/mysql -h${db.local.host} -u${db.local.user}<br /> -p ${db.local.pass}<br /> ${db.local.name} &lt; ${project.basedir}/up.sql&quot;<br /> dir=&quot;${project.basedir}&quot;<br />checkreturn=&quot;true&quot;&gt; <br />&lt;/target&gt;<br />
    53. 53. Pitfalls<br />Make sure you have a good CLI app for loading a SQL file<br />/usr/bin/mysql<br />mysql.exe<br />Build script travelling across operating systems?<br />Write your own Phing task to execute the migration output?<br />Was the changelog table created in the first place?<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />53<br />
    54. 54. Doctrine Database Migrations<br />Integrated into the Doctrine CLI tool<br />./doctrine migrate<br />Same philosophies<br />BUT, deltas are PHP objects that contain an UP and a DOWN method<br />Run using the Phing exec task<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />54<br />
    55. 55. Other Database Migration Tools<br />http://www.liquibase.org/<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />55<br />
    56. 56. Closing Thoughts<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />56<br />
    57. 57. Further Resources<br />The people around you<br />More people than you know automate their deployment<br />There are many, many different techniques<br />My techniques may suck for your particular setup<br />#phpcon freenode<br />Many of the speakers hang out there<br />Many smart people hang out there<br />I HANG OUT THERE!<br />Therefore I am smart<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />57<br />
    58. 58. Further Resources<br />Blogs<br />http://phpdeveloper.org<br />Documentation<br />http://phing.info<br />http://dbdeploy.com<br />Google<br />Experimentation<br />Pushing to a local directory<br />Pushing to a virtual machine<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />58<br />
    59. 59. Questions?<br />ZendCon &apos;09<br />Automated Deployment With Phing - Daniel Cousineau<br />59<br />
    60. 60. http://joind.in/937<br />
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×