1. Go to this page and download the library: Download stilch/path-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/ */
stilch / path-locator example snippets
use PathLocator\Exception\PathNotFoundException;
use PathLocator\PathLocator;
_DIR__);
//Add storage directory and return full path to storage directory
$pathLocator->addPath('storageDir', 'storage');
//Returns the full path to the file image.png without checking for file existence
$pathLocator->locate('storageDir', 'image.png', false);
try {
//Returns the full path to the file image.png or exception if file not exists
$pathLocator->locate('storageDir', 'image.png');
} catch (PathNotFoundException $e) {
//Exception handling
}
//Create a temporary directory and add to pathLocator
$tempDir = $pathLocator->locate('storageDir', 'temp', false);
if (!is_dir($tempDir)) {
mkdir($tempDir, 0555);
}
$pathLocator->addPath('tempDir', $tempDir, true);
//Add a temporary system directory and return the full path to it
$pathLocator->addPath('systemTemp', sys_get_temp_dir(), true);
//Returns the path to a temporary file in the system temporary directory
$pathLocator->locate('systemTemp', 'someTmpFile.tmp', false);
//Returns the path to a temporary file in the temporary directory of the project
$pathLocator->locate('tempDir', 'someTmpFile.tmp', false);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.