How do I get application's root directory within an action?
In order to get the root directory path, you can use _DIR_ or dirname(). echo dirname(__FILE__); Both the above syntaxes will return the same result.
Double-click the hard drive under the right panel's Hard Disk Drives list. For your system drive, double-click the "C" drive. You should now see all the files and folders in the root folder of your hard drive.
Right click on the game in the steam library.. then select properties.. local files.. browse local folder. That'll get you there.
The first thing ZF2 does is to change the current dir via chdir(dirname(__DIR__));
This means that every future include is based off of the ROOT PATH of your application and NOT the public folder. Or any other current folder.
Of course this only holds true for PHP-Files.
If you want to define the root path manually, you'd go to /public/index.php
and add a line like define('ROOT_PATH', dirname(__DIR__));
As i said before, for INCLUDES this is NOT required though ;) as you're ALWAYS in the root folder when it comes to PHP-Files ;)
getcwd() works best for me, DIR return the module root. Which isn't much use in this case
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