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
- Open “Preferences” > “PHP” > “General”
- “PHP 5 Interpeter” set to phpenv’s PHP path. eg:
/usr/local/phpenv/shims/php
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
- Open “Preferences” > “PHP” > “Frameworks & Tools”
- Select “PHPUnit”
- Set custom script paths, it’s you created above.
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.