How can I getcwd() in a PHP script in the Phar archive when called from the console?
Consider this call:
/path/to/my/actual/cwd> php index.php
In this case, getcwd() will return /path/to/my/actual/cwd . Now we take the same script, put it in Phar and call it like this:
/path/to/my/actual/cwd> php /path/to/my/phar/archive.phar
This time getcwd() will return /path/to/my/phar , since this is the current working directory of the Phar archive, but I did not call the archive from this directory, the cwd console is different.
How can i get this?
Or even better, how can I make all Phar scripts think their cdd is console?
source share