grinderspro / directory-manipulator
Simple folder manipulation. Create, delete, rename folder
1.0.31
2018-06-17 17:47 UTC
Requires
- php: >=5.4.0
README
This package allows you to simply work with directories. Create, delete, rename and empty directories.
Installation
You can install the package via composer:
composer require grinderspro/directory-manipulator
Usage
Simple create a directory
To create a directory, use the create()
method. If you use the create()
method without parameters, then the directory will be created in the temporary system folder by default.
require __DIR__ . '/vendor/autoload.php'; use Grinderspro\DirectoryManipulator\DirectoryManipulator; (new DirectoryManipulator())->create();
Create many directories
$dm = (new DirectoryManipulator())->location('/var/tmp/')->clear(); for ($i=1; $i<=10; ++$i) { $dm->name('gm'.$i)->create(); }
Create directory - "/var/tmp/{time()}"
(new DirectoryManipulator())->location('/var/tmp/')->name()->create();
Create directory - "/var/tmp/grinderspro"
(new DirectoryManipulator())->location('/var/tmp/')->name('grinderspro')->create();
(new DirectoryManipulator())->location('/var/tmp/grinderspro')->create();
if((new DirectoryManipulator())->location('/var/tmp/grinderspro')->create()) return true;
To get the full path of the newly created directory, use the path()
method without parameters.
$dirName = (new DirectoryManipulator())->create('/var/tmp/')->name()->path();
Delete directories
(new DirectoryManipulator())->location('/var/tmp/')->name('grinderspro')->delete();
(new DirectoryManipulator())->location('/var/tmp/grinderspro')->delete();
Clear directory
(new DirectoryManipulator())->location('/var/tmp/grinderspro')->clear();