Skip to content

Instantly share code, notes, and snippets.

@carbontwelve
Last active June 24, 2021 06:10
Show Gist options
  • Save carbontwelve/9089985 to your computer and use it in GitHub Desktop.
Save carbontwelve/9089985 to your computer and use it in GitHub Desktop.
Running xdebug in the console, for debugging Laravel artisan commands. Useful as I keep forgetting this one...
# Running xdebug in the console, for debugging Laravel artisan commands. Useful as I keep forgetting this one...
php -dxdebug.remote_autostart artisan
#Running phpcs for 5.3:
phpcs -pv --standards= --runtime-set testVersion 5.3 --ignore=*/public/*,*.js,*.css,*/tests/*,*/views/training/* .
@charlmert
Copy link

I believe it's xdebug_break(); on the line you wish to break. Recommend using with xdebug chrome app.

@melihovv
Copy link

I use PhpStorm and simple add breakpoints there. Thanks for posting!

@ryancwalsh
Copy link

I haven't been able to get Xdebug working with Artisan console commands. https://stackoverflow.com/q/27936323/470749 looks like it might help.

@hfmikep
Copy link

hfmikep commented Nov 9, 2017

For PHPStorm, simply setup running the command within PHPStorm.

Go to Menu item Run->Edit Configurations
Create a new PHP Script (hit the + symbol).

Give it a name.
For the File choose the artisan file.
Put the artisan comment in the "Arguments".
And Select the project root for the "Custom Working Directory"

No you can set breakpoints anywhere in the code and run it by going to the menu item: Run->Debug

What it is really doing is calling php with the following arguments.
php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 /Users/mikep/Projects/myproject/artisan report:codes

@gradzio
Copy link

gradzio commented Feb 9, 2018

thank you @hfmikep

@vladan-me
Copy link

That did the trick @hfmikep
It seems that Arguments are actually the command you want to run (everything that comes after PHP artisan)

@dericlima
Copy link

@hfmikep Thanks sharing this. Yeah @vladan-me, the Arguments are the artisan command that you want to run.
On my case I have some custom job that I need to debug, so for example, if the argument name is myjob:run (php artisan myjob:run) you just need to set myjob:run in the Arguments.

@leanwebstart
Copy link

Thanks... Great when first google search results brings you the answer directly...

@wdmtech
Copy link

wdmtech commented May 18, 2018

I want your babies

@fabianocruzdf
Copy link

Thanks @hfmikep!

@nrnazifi
Copy link

Do you know how can I set it for eclipse? After running the command, PHP debug is run in the Eclipse but does not come on Breakpoints!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment