From 1a44f505203d1d85aacf0fd9123f1d1abffe20ec Mon Sep 17 00:00:00 2001 From: Markus Hausammann Date: Wed, 14 Nov 2012 18:57:31 +0200 Subject: [PATCH] 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