Switch on debug only after a certain value
Hello,
how can I "turn on" the debugger in PhpStorm from a certain file which contains a certain value to be read first?
By this I mean.
I'm currently working on importing the data into Drupal, the import into Drupal is designed so that the individual imports are interdependent, that is, the data build on each other and for me the values of the last file that is read is interesting and important.
Is this possible?
Thank you in advance.
Please sign in to leave a comment.
Hi there,
I assume we are talking about PHP debug/Xdebug here, right?
I got the overall idea but still not sure on what exactly you need here (not using Drupal myself and your description is very broad)... but you have these few options:
1) Code your "need to trigger debug now" logic in PHP and when your condition is met just call xdebug_break(); -- it will initiate a debug session and put a breakpoint at that line. Until such line gets executed your code will be run normally (no debugger attached).
The actual logic (the "if" condition to check if it's time to break or not) is optional -- e.g. if you know for sure that after this line your data is already fully collected then just call then function without extra conditions.
2) Just use conditional breakpoints: the debug session will be in place from the start .. but the actual breakpoint will be triggered only when certain condition is met (no changes in your PHP code required; condition is checked by IDE/Xdebug) -- https://www.jetbrains.com/help/phpstorm/using-breakpoints.html#breakpoint-properties:
The difference to #1 is: not altering your PHP code; slower execution (as condition must be evaluated every time that line gets executed and it's slower than the actual compiled PHP code); conditions are relatively simple (e.g. unlikely to be able to call a function to read a file or something complex like that).
Hi,
yes I talk about "debug", I apologize for my spelling mistake.
The answer is enough for me.