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 in PHP by kartik
• 30,930 points
50 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 by Niroj
• 67,020 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 in PHP by Niroj
• 67,020 points
80 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 in PHP by Niroj
• 67,020 points
38 views
0 votes
1 answer

What is a Cookie? How to create Cookies With PHP?

A cookie is often used to identify ...READ MORE

answered Feb 13 in PHP by Niroj
• 67,020 points
337 views
0 votes
1 answer

What are the best way to allow plugins for a PHP application?

Hii, Here is an approach I have  used, it's ...READ MORE

answered Apr 1 in PHP by Niroj
• 67,020 points
83 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 in JQuery by Niroj
• 67,020 points
813 views
0 votes
1 answer
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 in PHP by Niroj
• 67,020 points
52 views
0 votes
1 answer

How to display HTML tags as plain text ?

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

answered Sep 17 in PHP by Niroj
• 67,020 points
80 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 in PHP by Niroj
• 67,020 points
546 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 17 in PHP by Niroj
• 67,020 points
47 views