Using Phing and PHPUnit with Symfony2

So recently I have been playing a lot with phing, symfony2, and Jenkins. Today I
will show you how to build a very basic build script that runs phpunit. Future
articles I will show you how to add to your build script to generate
documentation and eventually integrate it all into Jenkins.

First we need to update our `composer.json` file to include phing and phpunit if it is not already there.

{% highlight json %}
“require-dev”: {
“phing/phing”: “*”,
“phpunit/phpunit”: “*”
{% endhighlight %}

Now we need to run the update command with composer to install the dependencies.

{% highlight bash %}
php composer.phar update phing/phing phpunit/phpunit
{% endhighlight %}

Awesome, now that we have both phing and phpunit, we can start on the build script.

**NOTE**: By default these are installed in `vendor/bin` however, if you have changed this, they might be installed elsewhere. [Composer Docs](

In your project root directory, create a `build.xml` and fill it with

{% highlight xml %}

{% endhighlight %}

This will now run phpunit by default. Give it a try by running `php vendor/bin/phing` and it will run all your unit tests.

That’s all there is to it. In the next few articles I will show you some more in depth examples and configuring the Symfony2 test environment.