sikofitt / retrorsum
This package is abandoned and no longer maintained.
The author suggests using the konsulting/project-root package instead.
Finds a file searching recursively from the current directory.
v1.0.0
2017-02-03 02:35 UTC
Requires
- php: >=5.6
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.0
- phpunit/phpunit: ^5.7
This package is auto-updated.
Last update: 2022-05-11 16:05:45 UTC
README
This is a simple thing that will search for a file traversing down from the current directory.
This came about because I was thinking of how I could find the base directory of a project without guessing with __DIR__."/../../../"
and without forcing an app/ directory or something.
I wanted to find a way to find the base directory of an app from a class.
At the moment it does not work if the path is a symlink.
Usage
use Sikofitt\Retrorsum\Finder; $finder = new Finder('autoload.php'); define('BASE_DIR', dirname((string)$finder));
or
define('BASE_DIR', dirname((string)(new Finder('autoload.php'))));
Although this could set BASE_DIR as an empty string if it found nothing.
$finder = new Finder('autoload.php'); if(true === $finder->isFound()) { define('BASE_DIR', dirname($finder->getPath())); } else { // Whatever your other method would be. }
License
GPL-3.0