How to use phpenv’s PHPUnit in NetBeans 8.0

Standard

If you are managed multiple PHP versions with phpenv, I’ll show you how to use the NetBeans with PHP tools such as PHPUnit.

How to use the php in phpenv environment

  1. Open “Preferences” > “PHP” > “General”
  2. “PHP 5 Interpeter” set to phpenv’s PHP path. eg: /usr/local/phpenv/shims/php

SS 2014-06-14 15.37.29

How to use the PHPUnit in phpenv environment

1. Create custom scripts

When you specify path in phpenv environment (eg. /usr/local/phpenv/shims/phpunit) to NetBeans, it is not recognized as a shell script.

So, let create a file with the extension .sh.

phpunit.sh

#!/usr/bin/env bash
XDEBUG_CONFIG="idekey=netbeans-xdebug" /usr/local/phpenv/shims/phpunit "$@"

Create this script file to /usr/local/phpenv/bin/phpunit.sh. and give a execute privileges.

NOTE: XDEBUG_CONFIG is a environment variable for xdebug.

phpunit-skelgen.sh

#!/usr/bin/env bash
/usr/local/phpenv/shims/phpunit-skelgen "$@"

create phpunit-skelgen as well.

2. Specify custom scripts path

  1. Open “Preferences” > “PHP” > “Frameworks & Tools”
  2. Select “PHPUnit”
  3. Set custom script paths, it’s you created above.

SS 2014-06-14 15.37.57

Another tools with phpenv

Also tools such as PHPMD and PHPCS, you can use phpenv environment in the NetBeans by providing a script file with the extension .sh in this way.

Let’s enjoy NetBeans with phpenv.

Leave a Reply