From 1a44f505203d1d85aacf0fd9123f1d1abffe20ec Mon Sep 17 00:00:00 2001 From: Markus Hausammann Date: Wed, 14 Nov 2012 18:57:31 +0200 Subject: [PATCH 1/6] new chapter about building, deployment and CI --- _posts/09-05-01-Building your Application.md | 95 ++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 _posts/09-05-01-Building your Application.md diff --git a/_posts/09-05-01-Building your Application.md b/_posts/09-05-01-Building your Application.md new file mode 100644 index 0000000..da039b3 --- /dev/null +++ b/_posts/09-05-01-Building your Application.md @@ -0,0 +1,95 @@ +--- +isChild: true +--- + +## Building and Deploying your Application {#build_title} + +If you find yourself doing manual database schema changes or running your tests manually before updating your files (manually), think twice! With every additional manual task needed to deploy a new version of your app, the chances for potentially fatal mistakes increase. Whether you're dealing with a simple update, a comprehensive build process or even a continuous integration strategy, build tools are your friend. + +### Control your deployment with Phing + +With [Phing](http://www.phing.info/) you can control your packaging, deployment or testing process from within a simple XML build file. Phing provides a rich set of tasks usually needed to install or update a web app and can be extended with additional custom tasks (written in PHP). + +Example of a Phing script (build.xml): + +{% highlight xml %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{% endhighlight %} + +### Continuous Integration + +> Continuous Integration is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily — leading to multiple integrations per day. Many teams find that this approach leads to significantly reduced integration problems and allows a team to develop cohesive software more rapidly. + +*Martin Fowler* + +There are different ways to implement continuous integration for PHP. Recently [Travis CI](https://travis-ci.org/) has become by far the easiest way to do CI. Travis CI is a hosted continuous integration service for the open source community. It is integrated with GitHub and offers first class support for many languages including PHP. + +Example of a Travis CI build script: + +{% highlight yml %} + + language: php + + # list any PHP version you want to test against + php: + # aliased to a recent 5.3.x version + - 5.3 + # aliased to a recent 5.4.x version + - 5.4 + + # optionally specify a list of environments, for example to test different RDBMS + env: + - DB=mysql + - DB=pgsql + + # execute any number of scripts before the test run, custom env's are available as variables + before_script: + - if [[ "$DB" == "pgsql" ]]; then psql -c "DROP DATABASE IF EXISTS hello_world_test;" -U postgres; fi + - if [[ "$DB" == "pgsql" ]]; then psql -c "create database hello_world_test;" -U postgres; fi + - if [[ "$DB" == "mysql" ]]; then mysql -e "create database IF NOT EXISTS hello_world_test;" -uroot; fi + + script: phpunit --configuration phpunit_$DB.xml --coverage-text + +{% endhighlight %} + +Further reading: + +* [Continuous Integration with Jenkins](http://jenkins-ci.org/) +* [Continuous Integration with Teamcity](http://www.jetbrains.com/teamcity/) \ No newline at end of file From 1baa0436df5fd6058cc9f3321b5ef716c465d5ef Mon Sep 17 00:00:00 2001 From: Markus Hausammann Date: Fri, 23 Nov 2012 23:03:24 +0200 Subject: [PATCH 2/6] added chef and capistrano to deployment chapter --- _posts/09-05-01-Building your Application.md | 36 ++++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/_posts/09-05-01-Building your Application.md b/_posts/09-05-01-Building your Application.md index da039b3..4701a75 100644 --- a/_posts/09-05-01-Building your Application.md +++ b/_posts/09-05-01-Building your Application.md @@ -4,11 +4,16 @@ isChild: true ## Building and Deploying your Application {#build_title} -If you find yourself doing manual database schema changes or running your tests manually before updating your files (manually), think twice! With every additional manual task needed to deploy a new version of your app, the chances for potentially fatal mistakes increase. Whether you're dealing with a simple update, a comprehensive build process or even a continuous integration strategy, build tools are your friend. +If you find yourself doing manual database schema changes or running your tests manually before updating your files (manually), +think twice! With every additional manual task needed to deploy a new version of your app, the chances for potentially +fatal mistakes increase. Whether you're dealing with a simple update, a comprehensive build process or even a continuous +integration strategy, build tools are your friend. -### Control your deployment with Phing +### Phing - Deployment with XML and PHP -With [Phing](http://www.phing.info/) you can control your packaging, deployment or testing process from within a simple XML build file. Phing provides a rich set of tasks usually needed to install or update a web app and can be extended with additional custom tasks (written in PHP). +[Phing](http://www.phing.info/) is the easiest way to get started with automated deployment in the PHP world. With Phing you can control your packaging, deployment or testing process from within a simple +XML build file. Phing provides a rich set of tasks usually needed to install or update a web app and can be extended +with additional custom tasks, written in PHP. Example of a Phing script (build.xml): @@ -18,7 +23,7 @@ Example of a Phing script (build.xml): + promptText="What's the target environment (development, production)?" useExistingValue="true" /> @@ -53,13 +58,32 @@ Example of a Phing script (build.xml): {% endhighlight %} +### Capistrano - The powerful Ruby alternative + +[Capistrano](https://github.com/capistrano/capistrano/wiki) is a system for *intermediate-to-advanced programmers* to execute commands in a structured, repeatable way on one or more remote machines. + +It is pre-configured for deploying Ruby on Rails applications, however people are **successfully deploying PHP systems** with it. Successful use of Capistrano depends on a working knowledge of Ruby and Rake. + +Dave Gardner's blog post [PHP Deployment with Capistrano](http://www.davegardner.me.uk/blog/2012/02/13/php-deployment-with-capistrano/) is a good starting point for PHP developers interested in Capistrano. + +###Chef - Ruby based system integration framework + +[Chef](http://www.opscode.com/chef/) is more than a deployment framework, it is a very powerful Ruby based system integration framework that doesn't just deploy your app but can build your whole server environment or virtual boxes. + +Chef resources for PHP developers: + +* [Three part blog series about deploying a LAMP application with Chef, Vagrant, and EC2](http://www.jasongrimes.org/2012/06/managing-lamp-environments-with-chef-vagrant-and-ec2-1-of-3/) +* [Chef Cookbook which installs and configures PHP 5.3 and the PEAR package management system](https://github.com/opscode-cookbooks/php) + ### Continuous Integration -> Continuous Integration is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily — leading to multiple integrations per day. Many teams find that this approach leads to significantly reduced integration problems and allows a team to develop cohesive software more rapidly. +> Continuous Integration is a software development practice where members of a team integrate their work frequently, +usually each person integrates at least daily — leading to multiple integrations per day. Many teams find that this +approach leads to significantly reduced integration problems and allows a team to develop cohesive software more rapidly. *Martin Fowler* -There are different ways to implement continuous integration for PHP. Recently [Travis CI](https://travis-ci.org/) has become by far the easiest way to do CI. Travis CI is a hosted continuous integration service for the open source community. It is integrated with GitHub and offers first class support for many languages including PHP. +There are different ways to implement continuous integration for PHP. Recently [Travis CI](https://travis-ci.org/) has done a great job of making continuous integration a reality even for small projects. Travis CI is a hosted continuous integration service for the open source community. It is integrated with GitHub and offers first class support for many languages including PHP. Example of a Travis CI build script: From e354d95842f65587956e0a006bcc2d833a776282 Mon Sep 17 00:00:00 2001 From: Markus Hausammann Date: Fri, 23 Nov 2012 23:10:15 +0200 Subject: [PATCH 3/6] line wraps for easier read --- _posts/09-05-01-Building your Application.md | 30 +++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/_posts/09-05-01-Building your Application.md b/_posts/09-05-01-Building your Application.md index 4701a75..9dfab93 100644 --- a/_posts/09-05-01-Building your Application.md +++ b/_posts/09-05-01-Building your Application.md @@ -4,15 +4,16 @@ isChild: true ## Building and Deploying your Application {#build_title} -If you find yourself doing manual database schema changes or running your tests manually before updating your files (manually), -think twice! With every additional manual task needed to deploy a new version of your app, the chances for potentially -fatal mistakes increase. Whether you're dealing with a simple update, a comprehensive build process or even a continuous -integration strategy, build tools are your friend. +If you find yourself doing manual database schema changes or running your tests manually before updating your files +(manually), think twice! With every additional manual task needed to deploy a new version of your app, the chances for +potentially fatal mistakes increase. Whether you're dealing with a simple update, a comprehensive build process or even +a continuous integration strategy, build tools are your friend. ### Phing - Deployment with XML and PHP -[Phing](http://www.phing.info/) is the easiest way to get started with automated deployment in the PHP world. With Phing you can control your packaging, deployment or testing process from within a simple -XML build file. Phing provides a rich set of tasks usually needed to install or update a web app and can be extended +[Phing](http://www.phing.info/) is the easiest way to get started with automated deployment in the PHP world. +With Phing you can control your packaging, deployment or testing process from within a simple XML build file. +Phing provides a rich set of tasks usually needed to install or update a web app and can be extended with additional custom tasks, written in PHP. Example of a Phing script (build.xml): @@ -60,15 +61,19 @@ Example of a Phing script (build.xml): ### Capistrano - The powerful Ruby alternative -[Capistrano](https://github.com/capistrano/capistrano/wiki) is a system for *intermediate-to-advanced programmers* to execute commands in a structured, repeatable way on one or more remote machines. +[Capistrano](https://github.com/capistrano/capistrano/wiki) is a system for *intermediate-to-advanced programmers* +to execute commands in a structured, repeatable way on one or more remote machines. -It is pre-configured for deploying Ruby on Rails applications, however people are **successfully deploying PHP systems** with it. Successful use of Capistrano depends on a working knowledge of Ruby and Rake. +It is pre-configured for deploying Ruby on Rails applications, however people are **successfully deploying PHP systems** +with it. Successful use of Capistrano depends on a working knowledge of Ruby and Rake. -Dave Gardner's blog post [PHP Deployment with Capistrano](http://www.davegardner.me.uk/blog/2012/02/13/php-deployment-with-capistrano/) is a good starting point for PHP developers interested in Capistrano. +Dave Gardner's blog post [PHP Deployment with Capistrano](http://www.davegardner.me.uk/blog/2012/02/13/php-deployment-with-capistrano/) +is a good starting point for PHP developers interested in Capistrano. ###Chef - Ruby based system integration framework -[Chef](http://www.opscode.com/chef/) is more than a deployment framework, it is a very powerful Ruby based system integration framework that doesn't just deploy your app but can build your whole server environment or virtual boxes. +[Chef](http://www.opscode.com/chef/) is more than a deployment framework, it is a very powerful Ruby based system +integration framework that doesn't just deploy your app but can build your whole server environment or virtual boxes. Chef resources for PHP developers: @@ -83,7 +88,10 @@ approach leads to significantly reduced integration problems and allows a team t *Martin Fowler* -There are different ways to implement continuous integration for PHP. Recently [Travis CI](https://travis-ci.org/) has done a great job of making continuous integration a reality even for small projects. Travis CI is a hosted continuous integration service for the open source community. It is integrated with GitHub and offers first class support for many languages including PHP. +There are different ways to implement continuous integration for PHP. Recently [Travis CI](https://travis-ci.org/) has +done a great job of making continuous integration a reality even for small projects. Travis CI is a hosted continuous +integration service for the open source community. It is integrated with GitHub and offers first class support for many +languages including PHP. Example of a Travis CI build script: From 8f15552dece7382f40c52d6ef894100c6be2223e Mon Sep 17 00:00:00 2001 From: Markus Hausammann Date: Thu, 29 Nov 2012 14:55:28 +0200 Subject: [PATCH 4/6] make chapter topic based instead of product based --- _posts/09-05-01-Building your Application.md | 93 ++++---------------- 1 file changed, 15 insertions(+), 78 deletions(-) diff --git a/_posts/09-05-01-Building your Application.md b/_posts/09-05-01-Building your Application.md index 9dfab93..00273ee 100644 --- a/_posts/09-05-01-Building your Application.md +++ b/_posts/09-05-01-Building your Application.md @@ -7,71 +7,36 @@ isChild: true If you find yourself doing manual database schema changes or running your tests manually before updating your files (manually), think twice! With every additional manual task needed to deploy a new version of your app, the chances for potentially fatal mistakes increase. Whether you're dealing with a simple update, a comprehensive build process or even -a continuous integration strategy, build tools are your friend. +a continuous integration strategy, [build automation](http://en.wikipedia.org/wiki/Build_automation) is your friend. -### Phing - Deployment with XML and PHP +Among the tasks you might want to automate are: + +* dependency management +* compilation, minification of your assets +* running tests +* creation of documentation +* packaging +* deployment + + +### Build Automation Tools + +Build tools can be described as a collection of scripts that handle common tasks of software deployment. The build tool +is not a part of your software, it acts on your software from 'outside'. [Phing](http://www.phing.info/) is the easiest way to get started with automated deployment in the PHP world. With Phing you can control your packaging, deployment or testing process from within a simple XML build file. Phing provides a rich set of tasks usually needed to install or update a web app and can be extended with additional custom tasks, written in PHP. -Example of a Phing script (build.xml): - -{% highlight xml %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -{% endhighlight %} - -### Capistrano - The powerful Ruby alternative - [Capistrano](https://github.com/capistrano/capistrano/wiki) is a system for *intermediate-to-advanced programmers* to execute commands in a structured, repeatable way on one or more remote machines. - It is pre-configured for deploying Ruby on Rails applications, however people are **successfully deploying PHP systems** with it. Successful use of Capistrano depends on a working knowledge of Ruby and Rake. Dave Gardner's blog post [PHP Deployment with Capistrano](http://www.davegardner.me.uk/blog/2012/02/13/php-deployment-with-capistrano/) is a good starting point for PHP developers interested in Capistrano. -###Chef - Ruby based system integration framework - [Chef](http://www.opscode.com/chef/) is more than a deployment framework, it is a very powerful Ruby based system integration framework that doesn't just deploy your app but can build your whole server environment or virtual boxes. @@ -93,34 +58,6 @@ done a great job of making continuous integration a reality even for small proje integration service for the open source community. It is integrated with GitHub and offers first class support for many languages including PHP. -Example of a Travis CI build script: - -{% highlight yml %} - - language: php - - # list any PHP version you want to test against - php: - # aliased to a recent 5.3.x version - - 5.3 - # aliased to a recent 5.4.x version - - 5.4 - - # optionally specify a list of environments, for example to test different RDBMS - env: - - DB=mysql - - DB=pgsql - - # execute any number of scripts before the test run, custom env's are available as variables - before_script: - - if [[ "$DB" == "pgsql" ]]; then psql -c "DROP DATABASE IF EXISTS hello_world_test;" -U postgres; fi - - if [[ "$DB" == "pgsql" ]]; then psql -c "create database hello_world_test;" -U postgres; fi - - if [[ "$DB" == "mysql" ]]; then mysql -e "create database IF NOT EXISTS hello_world_test;" -uroot; fi - - script: phpunit --configuration phpunit_$DB.xml --coverage-text - -{% endhighlight %} - Further reading: * [Continuous Integration with Jenkins](http://jenkins-ci.org/) From 45dc8214aa1213e6f34537e4c9303ee60f52462d Mon Sep 17 00:00:00 2001 From: Markus Hausammann Date: Thu, 29 Nov 2012 15:24:23 +0200 Subject: [PATCH 5/6] add information about ant and maven --- _posts/09-05-01-Building your Application.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/_posts/09-05-01-Building your Application.md b/_posts/09-05-01-Building your Application.md index 00273ee..8b08603 100644 --- a/_posts/09-05-01-Building your Application.md +++ b/_posts/09-05-01-Building your Application.md @@ -22,12 +22,15 @@ Among the tasks you might want to automate are: ### Build Automation Tools Build tools can be described as a collection of scripts that handle common tasks of software deployment. The build tool -is not a part of your software, it acts on your software from 'outside'. +is not a part of your software, it acts on your software from 'outside'. + +There are many open source tools available to help you with build automation, some are written in PHP others aren't. +This shouldn't hold you back from using them, if they're better suited for the specific job. Here are a few examples: [Phing](http://www.phing.info/) is the easiest way to get started with automated deployment in the PHP world. With Phing you can control your packaging, deployment or testing process from within a simple XML build file. -Phing provides a rich set of tasks usually needed to install or update a web app and can be extended -with additional custom tasks, written in PHP. +Phing (which is based on [Apache Ant](http://ant.apache.org/)) provides a rich set of tasks usually needed to install or +update a web app and can be extended with additional custom tasks, written in PHP. [Capistrano](https://github.com/capistrano/capistrano/wiki) is a system for *intermediate-to-advanced programmers* to execute commands in a structured, repeatable way on one or more remote machines. @@ -45,6 +48,11 @@ Chef resources for PHP developers: * [Three part blog series about deploying a LAMP application with Chef, Vagrant, and EC2](http://www.jasongrimes.org/2012/06/managing-lamp-environments-with-chef-vagrant-and-ec2-1-of-3/) * [Chef Cookbook which installs and configures PHP 5.3 and the PEAR package management system](https://github.com/opscode-cookbooks/php) +Further reading: + +* [Automate your project with Apache Ant](http://net.tutsplus.com/tutorials/other/automate-your-projects-with-apache-ant/) +* [Maven](http://maven.apache.org/), a build framework based on Ant and [how to use it with PHP](http://www.php-maven.org/) + ### Continuous Integration > Continuous Integration is a software development practice where members of a team integrate their work frequently, From bcff8df579e78c33f16c990edacc3866b245d4f4 Mon Sep 17 00:00:00 2001 From: Markus Hausammann Date: Sun, 2 Dec 2012 03:23:36 +0200 Subject: [PATCH 6/6] capitalise bullet points --- _posts/09-05-01-Building your Application.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/_posts/09-05-01-Building your Application.md b/_posts/09-05-01-Building your Application.md index 8b08603..66e99dc 100644 --- a/_posts/09-05-01-Building your Application.md +++ b/_posts/09-05-01-Building your Application.md @@ -11,12 +11,12 @@ a continuous integration strategy, [build automation](http://en.wikipedia.org/wi Among the tasks you might want to automate are: -* dependency management -* compilation, minification of your assets -* running tests -* creation of documentation -* packaging -* deployment +* Dependency management +* Compilation, minification of your assets +* Running tests +* Creation of documentation +* Packaging +* Deployment ### Build Automation Tools