1

My current setup involve PhpStorm IDE in which I have imported Symfony 3 projects which is basically CLI tool. On the host machine I don't have PHP installed so I'm running the application from Docker container which has PHP and Xdebug installed.

I don't have issues to debug web applications from Docker containers but with Symfony and this CLI tool it seems a little bit more tricky.

My question is how to properly set this up and debug it from PhpStorm? I tried to create a new debug configuration (PHP Remote Debug) but breakpoints are not trigged.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
tslid
  • 315
  • 1
  • 4
  • 16
  • Why do you try to create a "PHP Remote Debug" configuration if you are telling that it's a CLI tool? You should create PHP Remote Interpreter and use "PHP Script" type of configuration .. which is for running/debugging CLI scripts (so that IDE will execute it in that Docker container). – LazyOne Oct 28 '17 at 14:53
  • I managed to trigger properly the debugger but now I have issue with timezone `PHP Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier.` I can confirm on 1000% that php.ini has timezone properly set and php -i shows that it is loaded. – tslid Oct 28 '17 at 22:41
  • Okay I solved it by passing the timezone as -d option (configured it in phpstorm interpreter options) but it is still really strange as my php.ini contains this settings. It seems like it is totally ignored. – tslid Oct 28 '17 at 23:14

1 Answers1

3

Suppossing you have followed into the instructions mentioned into the following links:

Or similar questions

Then you need to follow theese steps:

Step1: Get shell access to your container via running:

docker exec -ti ^container_id^ /bin/sh

Or if running a debian/ubuntu based one (or you installed manually bash):

docker exec -ti ^container_id^ /bin/bash

The ^container_id^ can be found via docker ps command it is the first column of the table. If running on a small window just pipe int into less -S resulting the command:

docker ps | less -S

Then export the following enviromental variables:

export PHP_IDE_CONFIG="serverName=0.0.0.0:5092"
export XDEBUG_CONFIG="idekey=PHPSTORM"

Please keep in mind to setup the correct value specified into Servers section as you see in the image:

Phpstorm settings

It is important in order not to run into the problem specified in this question.

Then just enable debugger listentin into the phpstorm and spawn the cli as you do when you run a symfony application.

Dimitrios Desyllas
  • 9,082
  • 15
  • 74
  • 164