https://github.com/sikofitt/retrorsum
This is a simple thing that will search for a file traversing down from the current directory.
https://github.com/sikofitt/retrorsum
file filesystem php php56 php7
Last synced: 11 days ago
JSON representation
This is a simple thing that will search for a file traversing down from the current directory.
- Host: GitHub
- URL: https://github.com/sikofitt/retrorsum
- Owner: sikofitt
- License: gpl-3.0
- Created: 2017-02-03T01:11:16.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-03T02:35:58.000Z (about 9 years ago)
- Last Synced: 2026-02-27T13:48:44.973Z (30 days ago)
- Topics: file, filesystem, php, php56, php7
- Language: PHP
- Size: 16.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```php
use Sikofitt\Retrorsum\Finder;
$finder = new Finder('autoload.php');
define('BASE_DIR', dirname((string)$finder));
```
or
```php
define('BASE_DIR', dirname((string)(new Finder('autoload.php'))));
```
Although this could set BASE_DIR as an empty string if it found nothing.
```php
$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