Skip to content

Simple folder manipulation. Create, delete, rename folder and more

Notifications You must be signed in to change notification settings

grinderspro/directory-manipulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple work with directories

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();

About

Simple folder manipulation. Create, delete, rename folder and more

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages