1. Go to this page and download the library: Download h4kuna/dir 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/ */
h4kuna / dir example snippets
class StorageDir extends \h4kuna\Dir\Dir
{
}
$storageDir = new StorageDir('/documet/root/data'); // dir in constructor does not check
$storageDir->create(); // if dir from constructor does not exist, let's check and create
$subDir = $storageDir->dir('foo/bar');
$filepath = $subDir->filename('lucky', 'jpg');
$filepath2 = $storageDir->filename('baz/foo/happy.jpg');
echo $filepath; // /documet/root/data/foo/bar/lucky.jpg
echo $filepath2; // /documet/root/data/baz/foo/happy.jpg
class MyClass {
public function __construct(private StorageDir $storageDir) {
}
}
use h4kuna\Dir;
try {
$fileInfo = (new Dir\Dir('/any/path'))
->create()
->checkWriteable()
->fileInfo('foo.txt');
} catch (Dir\Exceptions\IOException $e) {
// dir is not writable
}
var_dump($fileInfo->getPathname()); // /any/path/foo.txt
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.