• 11

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 187


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 187
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Xdebug laravel artisan commands

I regularly use xdebug to debug applications, I've built a laravel application that takes an upload of a csv inserts the data to the database and the ids to a job queue.

I've written an artisan command to be run via cron to then do something with this data.

Xdebug works for accessing the site via the browser, but its not breaking on breakpoints when ran from cli.

I run php5-fpm. My files /etc/php5/fpm/php.ini and /etc/php5/cli/php/ini both contain the following settings:

xdebug.remote_enable = 1 
xdebug.idekey = 'dev_docker' 
xdebug.remote_autostart = 1 
xdebug.remote_connect_back = {{my host ip}} 
xdebug.remote_port = 9000 

I then run the artisan command

php artisan jobqueue::process --batch-size=10 --sleep=10

I know the command is running as ->info('text') is displayed in the terminal

Anyone know what I'm missing?

Maybe this will help someone.

In short I had the same problem but I didn't have luck with accepted answer. My solution is to run this from the command line:

php -dxdebug.remote_enable=1 -dxdebug.remote_autostart=on -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host= artisan my:command
  • 14
Reply Report

I got it working with remote_autostart=1 and setting the PHP_IDE_CONFIG environment variable to "serverName=localhost". localhost is the name of your server config in PHPStorm. Now when I run php artisan I can break at the regular breakpoints.

Let me be more clear :)

If you've got xdebug working with PHPStorm and regular requests this is what you should do to get it working with command line php (artisan).

You have configured paths in PHPStorm so it knows which file it should show you with the breakpoints. These paths are configured under a server (Preferences -> Languages & Frameworks -> PHP -> Servers).

The name of this server should be the serverName value in the PHP_IDE_CONFIG environment variable.

  • 0
Reply Report