Debugging for console seems not to work properly


#1

At the moment, i am experiencing a very strange behaviour.
Debugging console commands is not possible at all, the breakpoint does not hit.

What i tried to do:

  1. Setting a breakpoint in DataImportBusinessFactory on line 328 ($dataSetStepBroker->addStep …) in my IntelliJ/PhpStorm IDE (under MacOS)

  2. Executing

vendor/bin/console data:import:product-concrete

from command line in vagrant vm.

Expecting:

  • Breakpoint stops at line 328
  • variable $dataSetStepBroker is initialized (done one line before according to source code with dataSetStepBroker = …)

Actual:

  • Breakpoint stops at line 328
  • variable $dataSetStepBroker is not set until now
  • if i step over to line 329, the variable is now set (even tough there is not such an command to do this)
  • further steps more the debugger stops on an empty line

So obviously there is a bug synchronizing sourcecode between vm and local dev. The IntelliJ is always one step ahead the real debugging line.

I found out, that this affects all classes loaded by the autoloader in vendor/bin/console php file. The vendor/bin/console itself debugs proper. So maybe autloading/symlinks causes the problem?

Any ideas?

Best regards


#2

Hi Jim!
You can try to add script to debug in PhpStorm:
go to Run -> Edit Configuration. Press plus and add new PHP Script.


And configure like this.
Than run this script with debug.

Best Regards,
Aleksey Kotsuba.


#3

I haven’t experienced this behaviour before, but following the academy topic on this, never failed me.

https://academy.spryker.com/getting_started/debugging/debugging_setup.html (the section of “Debugging Console Commands”)


#4

Unfortunately same behaviour for local debugging setting :confused:


#5

Do you also work with vagrant/intellij/MacOS? That would leaving me hopeful … i’ll try to start completely on a fresh installation


#6

Yes, you are running the command from within the devvm, right?


#7

Yes i do. But i also tried outside.


#8

Ok i reinstalled the whole thing. Same behaviour for console commands.

In vm executing

XDEBUG_CONFIG=“remote_host=10.10.0.1” PHP_IDE_CONFIG=“serverName=zed” vendor/bin/console data:import:product-concrete

Breakpoint set on line 328.

Result: Breakpoint stops but is factual in line 327.

Debugging via frontend works fine.

What else can i do?


#9

I found out that only files from src/ folder are affected. All vendor code works and hits the correct line. just the existing code in src/ does not work properly. But only for command line executed PHP. My guess is, that the PHP_IDE_CONFIG=“serverName=zed” has no effect to the IDE … it does not matter if I write something like PHP_IDE_CONFIG=“serverName=zed” or PHP_IDE_CONFIG=“serverName=dfjkofkdfpmpmw” the result is still the same.

Edit:
Okay, it just seems it works correct. If i set a breakpoint on the line which is shown in the stack, it will not stop here … this is really weird and frustrating

Edit 2:
Ok, only console.php works properly … all other files (included) don’t work properly.

Edit 3:
I duplicated the line “require_once SPRYKER_COMPOSER_INSTALL;” in console.php by mistake … but now the breakpoints seems to work properly.

I pressed cmd+z to undo these changes to track that this really issues the problem. But … the debugger still works correct.
Can somebody explain me this behavior? :thinking:

Edit 4:
The correct debugging behavior is gone again now, the debugger stops at the wrong line again … i can’t reproduce a working state. Duplicating the code line from edit above does not trigger the correct debugging behavior … :confused: