一直在用最原始的方式做PHP开发。
今天忙里偷闲,温习了一下xdebug, composer, phpunit三大工具的安装和使用
centos 6环境 , php5.6
XDEBUG
1. xdebug , 从官网下载xdebug的源码, 然后解压出来,参照readme中的要求处理:
2. cd xdebug-2.2.x
3. Run phpize: phpize (or /path/to/phpize if phpize is not in your path).
4. ./configure --enable-xdebug (or: ../configure --enable-xdebug --with-php-config=/path/to/php-config if php-config is not in your path)
5. Run: make
6. cp modules/xdebug.so /to/wherever/you/want/it
7. add the following line to php.ini:
zend_extension="/wherever/you/put/it/xdebug.so"
8. Restart your webserver.
9. Write a PHP page that calls "phpinfo();" Load it in a browser and look for the info on the xdebug module. If you see it, you have been successful!
COMPOSER
https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx
1. curl -sS https://getcomposer.org/installer | php
2. mv composer.phar /usr/local/bin/composer
3. 在项目根目录下创建一个composer.json文件,内容可以是
{ "require": { "monolog/monolog": "1.0.*" } }
4. 执行 composer install,会自动创建vendors目录并下载相应依赖
5. 在文件中加入 require __DIR__ . '/vendor/autoload.php';
composer的国内镜像站点 http://www.phpcomposer.com/
PHPUNIT
https://phpunit.de/getting-started.html
安装和使用均有介绍
➜ wget https://phar.phpunit.de/phpunit.phar ➜ chmod +x phpunit.phar ➜ sudo mv phpunit.phar /usr/local/bin/phpunit ➜ phpunit --version