How to trigger XDebug profiler for a command line PHP script

0 votes
XDebug offers the configuration directive "xdebug.profiler_enable_trigger" that allows to activate profiling by passing the GET or POST parameter "XDEBUG_PROFILE" when calling a script via HTTP. This is handy if you don't want profiling for ALL of your scripts but only for a few special cases without always changing your PHP configuration.

Is there a way to achieve the same behavior for command line PHP programs? I tried to pass the "XDEBUG_PROFILE" as a command line argument but it didn't work.

In general, profiling command line PHP works well, but I'd like to have the same per-call-flexibility as with a browser and HTTP server.

Any suggestions?
Sep 17, 2020 in PHP by kartik
• 37,520 points
1,652 views

1 answer to this question.

0 votes

Hello @kartik,

You can pass INI settings with the -d flag: php -d xdebug.profiler_enable=On script.php.

Hope it helps!!
Thank You!!

answered Sep 17, 2020 by Niroj
• 82,840 points

Related Questions In PHP

0 votes
1 answer

How to execute a MySQL command from a shell script?

Hello @kartik, You need to use the -p flag to ...READ MORE

answered Aug 20, 2020 in PHP by Niroj
• 82,840 points
3,670 views
0 votes
1 answer

How to execute PHP code from the command line?

Hello @kartik, the php command offers two switches to ...READ MORE

answered Oct 1, 2020 in PHP by Niroj
• 82,840 points
1,883 views
0 votes
1 answer

How to add a line break within echo in PHP?

Hello @kartik, You have to use br when ...READ MORE

answered Oct 27, 2020 in PHP by Niroj
• 82,840 points
3,137 views
0 votes
1 answer

How to create and download a csv file from php script?

Hello @kartik, You can use the built in fputcsv() for ...READ MORE

answered Oct 27, 2020 in PHP by Niroj
• 82,840 points
7,101 views
0 votes
1 answer

Uncaught ReferenceError:Karma: jQuery is not defined

Hii @kartik, You first have to load jQuery ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,840 points
5,108 views
0 votes
1 answer

Error:PHP Warning: POST Content-Length of 8978294 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

Hello @kartik, 8388608 bytes is 8M, the default ...READ MORE

answered Sep 17, 2020 in PHP by Niroj
• 82,840 points
28,548 views
0 votes
1 answer

How to remove all special characters from a string?

Hello @kartik, This should do what you're looking ...READ MORE

answered Sep 17, 2020 in PHP by Niroj
• 82,840 points
11,456 views
0 votes
1 answer

How to display HTML tags as plain text ?

Hello @kartik, Replace < with &lt; and& ...READ MORE

answered Sep 17, 2020 in PHP by Niroj
• 82,840 points
2,754 views
0 votes
1 answer

How to find the php.ini file from the command line?

Hello @kartik, You can get a full phpinfo() using : php ...READ MORE

answered May 19, 2020 in PHP by Niroj
• 82,840 points
53,973 views
0 votes
1 answer

How to get a list of user accounts using the command line in MySQL?

Hello @kartik, Use this query: SELECT User FROM mysql.user; Which ...READ MORE

answered Aug 18, 2020 in PHP by Niroj
• 82,840 points
1,571 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP