Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use phpstorm debug tool yasd

Shulou Source: shulou.com Published: 2022-06-01 00:54:02 10月13日 Update

How to use the phpstorm debug tool yasd, aiming at this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.

Usually, in development, there will always be times when debug is needed. Manual breakpoints such as var_dump and die are always time-consuming and not elegant. At this time, someone may choose to install the xdebug extension and configure xdebug in the phpstorm to debug.

But when you need to use the swoole framework, and need to debug the code in the swoole framework, xdebug can not be used on swoole, there is a conflict with swoole.

Then I found an easy-to-use debug debugging tool that is compatible with fpm framework and swoole framework, yasd.

Installation

1. Install the boots library on Mac

Brew install boost

two。 Download yasd source code from Github

Git clone https://github.com/swoole/yasd.git

3. Compile and install yasd

Cd yasdphpize-- clean & &\ phpize & &\. / configure & &\ make clean & &\ make &\ make install

4. Modify php.ini

Zend_extension= "yasd.so"; command line debugging; yasd.debug_mode=cmd; remote debugging yasd.debug_mode=remote; local development address yasd.remote_host=127.0.0.1; local development listening port yasd.remote_port=9000

View extended information

➜yasd php-- ri yasdyasdYasd = > enabledAuthor = > codinghuang Version = > 0.3.9-alphaBuilt = > Jan 15 2022 14:09:47Directive = > Local Value = > Master Valueyasd.breakpoints_file = > no value = > no valueyasd.debug_mode = > remote = > remoteyasd.remote_host = > 127.0.0.1 = > 127.0.0.1yasd.remote_port = > 9000 = > 9000yasd.depth = > 1 = > 1yasd.log_level = >-1 = >-1yasd.max_executed_opline_num = > 0 = > 0yasd.init_file = > no value = > no valueyasd .open _ extended_info = > 0 = > 0xdebug.coverage_enable = > 1 = > 1xdebug.profiler_enable = > 1 = > 1xdebug.remote_autostart = > 1 = > 1xdebug.remote_connect_back = > 0 = > 0xdebug.remote_mode = > req = > reqxdebug.idekey = > hantaohuang = > hantaohuang

5. Debug script

To debug a script using yasd, you must add the php parameter of-e, such as this

# debugging ordinary php script php-e test.php# debugging laravel's commandphp-e artisan test# debugging hyperf framework php-e bin/hyperf start

Configure phpstorm

1. Configure phpstorm to listen on port 9000

two。 Click the phone icon in the upper right corner of phpstorm to start monitoring

3. Test debug debugging

Write a random test command in Laravel

Php-e artisan test

It has been a success since we got here.

Debug Hyperf framework

It said above to debug in fpm, and then let's talk about how to debug in Hyperf framework.

A few points to pay attention to

1. In Hyperf, you need to set the scan_cacheable parameter in config.php to true, which is whether to scan the proxy class. If set to true, each startup will directly scan the cache proxy class instead of rescanning the generation proxy class.

Once set to true, it should be noted that each modification of the code requires manual generation of the proxy class, composer dump-autoload-o, and then at startup.

Or modify the code directly in the proxy class, and then copy the code in the proxy class to the real class when the debug is over.

The proxy class generation path is in runtime/container/proxy

2. If Swoole Server is used in the Hyperf framework, you need to set worker_num to 1 or the breakpoint may not take effect. This parameter is in server.php.

The rest of the debugging is no different from what was mentioned above.

The answer to the question about how to use the phpstorm debug tool yasd is shared here. I hope the above content can be of some help to everyone. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

Tags: Framework agents parameters tools code scripts questions development generation monitoring configuration manual more ports help solutions normal easy ordinary elegant Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Huawei Microsoft MySQL vpn