PHP code example of morebec / file-locator
1. Go to this page and download the library: Download morebec/file-locator library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
morebec / file-locator example snippets
$locator = new FileLocator();
$file = $locator->find(
'composer.json',
Directory::fromStringPath(getcwd()),
FileLocatorStrategy::RECURSIVE_UP()
);
if(!$file) {
throw new \Exception('Composer could not be found.');
}
// Parse composer file
$composerConfig = json_decode($file->getContents(), true);