Set up PHP development environment
###Notes of Set up PHP development environment
- Install Eclipse PDT;
- Install PEAR and PECL on Mac OS X, php.ini locate in /etc on Yosemite;
- Install Xdebug through PEAR/PECL;
Addition configure for Yosemitesudo cp /etc/php.ini.default /etc/php.ini
- add “zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so” to php.ini
-
Debugging Local PHP Files (PHP CLI Application)
- Create a PHP project;
- Create a PHP file;
- Set a breakpoint in PHP file;
- Save file;
- Create a new debug configuration;
- Eclipse > Preference… > PHP Executables > Add (Executable path:
which php
) - Run > Debug Configurations > Select PHP CLI Application > New
- Eclipse > Preference… > PHP Executables > Add (Executable path:
- Debugging PHP Web Applications (PHP Web Application)
- Create a PHP project;
- Create a PHP file;
- Create a new debug configuration;
- Run > Debug Configurations > Select PHP Web Application > New
- Test with PHPUnit
- Run > External Tools > External Tools Configurations… > Program > New [Main] Location:/usr/local/bin/phpunit Working Directory:${workspace_loc:/Backend/tests} Apply > Run Reference
- Integrate MakeGood (failure)
- Installing Prerequisite Software
- PHP 5.5.27 (cli)
- xdebug-2.3.2
- eclipse mars(4.5.0)
- PDT(3.5.0)
- PHPUnit (4.8.6)
-
Installing MakeGood Help -> Install New Software… -> Add… -> http://eclipse.piece-framework.com/
-
Selecting a Testing Framework
-
Resolving the Dependencies to the Testing Framework * Defining User Libraries Eclipse -> Preferences… > PHP -> PHP Libraries > New… > OK Add External folder… > Verifying the include path * Adding User Libraries to the Project
fail with PHPUnit_Framework_TestCase class is not available. Fix…, I doubt that MakeGood doesn’t support eclipse mars.
*Testing Framework Specific Configuration
PHPUnit * Open the properties for the project. * Select MakeGood. * Select PHPUnit. * Specify the XML Configuration File. eg - Installing Prerequisite Software
###Throw java.lang.NullPointerException when create a new debug configuration
Solution: Add a PHP Executable, Eclipse > Preference… > PHP Executables > Add (Executable path: which php
)
###Wait for XDebug session
Solution:Debugging PHP Web Applications时卡在这里,原因是XDebug remote debug没配置好,参考了Remote Debugging和Debugging using XDebug,发现phpinfo()输出的内容并没有XDebug。于是来开始配置php.ini,参考的How to set default php.ini to be used, OSX Yosemite
sudo cp /etc/php.ini.default /etc/php.ini
// Add follow content to php.ini
[XDebug]
zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so
xdebug.remote_enable=On
xdebug.remote_handler=dbgp
xdebug.remote_host=helloworld.local
xdebug.remote_port=9000
;xdebug.remote_connect_back=1
xdebug.remote_mode="req"
xdebug.remote_log="/var/log/xdebug.log"
sudo apachectl restart
###/private/tmp/pear/install/xdebug/xdebug.c:25:10: fatal error: ‘php.h’ file not found
Solution:
$ xcode-select --install
Reference:http://stackoverflow.com/questions/19531262/cant-phpize-or-configure-an-extension-in-os-x-10-9-mavericks