Go to file
R. Eric Wheeler ee3df78313 updated example 2017-02-02 18:35:22 -08:00
Tests Initial commit 2017-02-02 17:06:29 -08:00
src/Sikofitt/Retrorsum updated example 2017-02-02 18:35:22 -08:00
.gitignore Initial commit 2017-02-02 17:06:29 -08:00
.php_cs Initial commit 2017-02-02 17:06:29 -08:00
LICENSE Initial commit 2017-02-02 17:06:29 -08:00
README.md updated example 2017-02-02 18:35:22 -08:00
composer.json Composer fix... geez 2017-02-02 17:25:30 -08:00
phpunit.xml Initial commit 2017-02-02 17:06:29 -08:00

README.md

Retrorsum

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