The preparation of the instruments

1. The xdebug extension

Download the xDEBUG extension from the xDEBUG website based on the PHP version (note whether the local PHP version is thread-safe or non-thread-safe), or put phpInfo () information into PHP version check and install as instructed

After downloading

Linux Version unzip:

The tar ZXVF xdebug - 2.7.0 beta1. TGZCopy the code

The installation package directory is displayed

CD xdebug - 2.7.0 beta1Copy the code

Generate the configure execution file

phpize

Copy the code

configuration

/ configure -- prefix = / usr/local/PHP - extention/xdebug - 2.7 - with - PHP - config = / usr/local/php7 / bin/PHP - configCopy the code

compile

make

Copy the code

The installation

make install

Copy the code

Successful installation

Modify php.ini to add the following at the end of the file

[Xdebug] zend_extension=xdebug.so xdebug.idekey=PHPSTORM ; The function for collecting Function parameters is enabled. Includes the parameter values of the function call in the monitoring information for the function procedure call. The default value of this configuration item is off. xdebug.collect_params = 1 ; Enable performance monitor xdebug.profiler_enable=on; Automatically opens "Monitor function call process" mode. This function outputs the monitoring information of a function call as a file in the directory you specify. The default value of this configuration item is off. xdebug.auto_trace=on ; Xdebug. trace_output_dir="/usr/local/php-extention/xdebug-2.7/xdebug.trace_output_dir"; Profiler_output_dir ="/usr/local/php-extention/xdebug-2.7/xdebug.profiler_output_dir"; Enable xdebug.remote_enable=on; Remote header request mode xdebug.remote_handler= DBGP; Remote address xdebug.remote_host=localhost; Remote port number xdebug.remote_port=9001Copy the code

2. Install phpunit

See phpUnit’s website

Phpunit can also be installed using Laravel Composer

3. Set the PhpStrom

Select the corresponding PHP

The xdebug port number selects the port you just configured in php.ini

Write test cases

php artisan make:test ExampleTest
Copy the code

Click Run Debug

This allows you to debug your PHP code natively