I am writing an PHP CLI app which loads YAML files. When trying to do this within an Xdebug session:
if (file_exists(__DIR__ . '/../../foo/bar') { /* ... */ }
__DIR__
allways is xdebug:
which will allways lead to false
from file_exists()
.
Is there any work around?
You can also set Xdebug's mode by setting the XDEBUG_MODE environment variable on the command-line; this will take precedence over the xdebug. mode setting, but will not change the value of the xdebug.
Xdebug allows you to break during code execution and inspect all the variables in scope during a request. What this means is you have everything you need to troubleshoot during only one iteration of this cycle.
XDebug works over the protocol that requires your local machine to listen for incoming connections from a server where an application you are debugging is located. You may already have used debugging tools that simply connect to a remote server or a process of your application.
Set $dir = __DIR__;
and use if (file_exists($dir . '/../../foo/bar')
. It will work like that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With