Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xdebug weird __DIR__ constant

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?

like image 399
Jan P. Avatar asked Jan 21 '14 09:01

Jan P.


People also ask

How do I set xdebug mode?

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.

What is the use of 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.

How does PHP xdebug work?

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.


1 Answers

Set $dir = __DIR__; and use if (file_exists($dir . '/../../foo/bar'). It will work like that.

like image 175
Zsolti Avatar answered Oct 05 '22 00:10

Zsolti