John Davidson

profiler - PHP-SPX - Seeing profiling results made by CLI command on the web GUI

0 comments
Message:


We want to see the speeds of services written in PHP, so we decided to use PHP-SPX (https://github.com/NoiseByNorthwest/php-spx)


To try it out, we got a simple script with a while(true) loop and we added spx_profiler_start() and spx_profiler_stop() within the loop. Between these method calls, there's my echo command to output something.


The CLI command is the following: SPX_ENABLED=1 SPX_REPORT=full SPX_AUTO_START=0 php testScript.php


The web GUI itself is working nicely when it comes to track the website calls via webbrowser, which is on the same server where we are using the CLI command. We can click on the entries seen in the results table, also all the graphs, etc. But we cannot see any entries involving the CLI calls and its results.


Are there maybe any setting we did not consider yet?



My Answer:
It seems like the issue might be related to the configuration of PHP-SPX for CLI usage. By default, PHP-SPX is configured to work with web requests, so you may need to make some adjustments to enable profiling for CLI commands.

One thing you can try is to set the SPX_AUTO_START environment variable to 1 before running your CLI command. This will automatically start the profiler for all PHP scripts, including CLI scripts. You can do this by running the following command before running your test script:


export SPX_ENABLED=1
export SPX_REPORT=full
export SPX_AUTO_START=1
php testScript.php


Additionally, you may need to check the PHP-SPX configuration file to ensure that CLI profiling is enabled. You can find the configuration file in the PHP-SPX repository or in your PHP configuration directory.

If you continue to experience issues, you may want to reach out to the PHP-SPX community or open an issue on their GitHub repository for further assistance.

Rate this post

3 of 5 based on 4771 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us