简体   繁体   中英

Get File Location using __DIR__

$appRoot = dirname(dirname(dirname(dirname(__DIR__))));
require $appRoot . '/app/bootstrap.php';
require __DIR__ . '/../vendor/autoload.php';

I am running the above functions. But I am not able to get the path of the outcome locations of autoload and bootstrap.php file. Can someone help me what will be the final location of the files which are used in the require functions.

C:\wamp64\www\magento2252\dev\tests\functional\utils

This is my current location of the file in which this code is written

The code

__DIR__ 

gives the current directory of the file. Hence in your case

__DIR__ = C:\wamp64\www\magento2252\dev\tests\functional\utils

dirname($var) gives the direct of a file or directory passed in as a parameter. Hence

dirname(__DIR__) = C:\wamp64\www\magento2252\dev\tests\functional

if you apply this iteratively you need

dirname(dirname(dirname(__DIR__)))

which refers to the C:\\wamp64\\www\\magento2252\\dev directory but you have used dirname 4 times

So you code should look like this

$appRoot = dirname(dirname(dirname(__DIR__)));
require $appRoot . '/app/bootstrap.php';
require $appRoot . '/../vendor/autoload.php';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM