Installing Laravel 4 With PHPUnit 3.8 using Composer

Laravel is PHPUnit ready, but one needs to configure the composer.json file to tell composer, the dependency manager, to install the PHPUnit packages.  If you want to use PHPUnit 3.8, you’ll need at least PHP 5.4.7.  If you haven’t already upgraded to PHP 5.4.7, there is no time like the present.  If not, just substitute version 3.8 with version 3.7 in the script below

The prerequisites are at least: unzip,curl,sed (in Ubuntu/Debian use ‘sudo apt-get install unzip’ to install)

The easy way that might work (I tested this on Ubuntu 12.04.2 LTS)

sudo curl -sS | php;wget -O; unzip; rm;mv laravel-master laravel;mv composer.phar laravel/;sed -i 's/laravel\/framework": "4\.0\.\*"/&,"phpunit\/phpunit": "3.8.*"/' laravel/composer.json;cd laravel;php composer.phar install;chmod -R 777 app/storage;php artisan key:generate

The longer way:

  • Download Composer

Run this in your terminal to get the latest Composer version:

curl -sS | php

Or if you don’t have curl:

php -r "eval('?>'.file_get_contents(''));"


  • Download Laravel 4

Use the following link:

  • Edit composer.json

change the following line:

 "laravel/framework": "4.0.*"


"laravel/framework": "4.0.*","phpunit/phpunit": "3.8.*"
  • Change into the directory laravel and then run
  • cd laravel;php composer.phar install
  • Observe that PHPUnit is present in the following extract of the output:

– Installing phpunit/php-timer (dev-master b871145)
Downloading: 100%

– Installing sebastian/version (dev-master 1.0.1)
Downloading: 100%

– Installing phpunit/php-text-template (dev-master 1eeef10)
Downloading: 100%

– Installing phpunit/phpunit-mock-objects (dev-master a35e634)
Downloading: 100%

– Installing phpunit/php-token-stream (dev-master c25dd88)
Downloading: 100%


N.B. I didn’t write this entire article, rather I copied and pasted pieces of documentation from the documentation on various websites and added my comments and script.

Posted in programming and web design and tagged , , , .

Leave a Reply

Your email address will not be published. Required fields are marked *