Search code examples
laravelphpunitlaravel-5.1cloud9-ide

How do I get phpunit to work in cloud9 IDE?


Just started out a laravel project on cloud9 IDE but I can't get phpunit to work. Every time I run the PHPUnit command I get a

command not found

response. From the file structure in the project I can see phpunit files. I have never used cloud 9 for a laravel project before so I can't really tell if thats how it's supposed to behave. Has anyone successfully used phpunit on cloud9 before?


Solution

  • You can install phpunit globally using composer (available in the default C9 workspace). Phpunit 4.8.* works with PHP 5.5.

    sudo composer global require phpunit/phpunit:4.8.*
    

    The phpunit executable will be installed in ~/.composer/vendor/bin/ so add the following line at the end of the ~/.profile file to make the command available elsewhere.

    export PATH=~/.composer/vendor/bin:$PATH
    

    Run source ~/.profile afterwards to register the new path then simply run phpunit in your Laravel installation folder.