项目作者: grinderspro

项目描述 :
Simple folder manipulation. Create, delete, rename folder and more
高级语言: PHP
项目地址: git://github.com/grinderspro/directory-manipulator.git
创建时间: 2018-03-11T21:03:50Z
项目社区:https://github.com/grinderspro/directory-manipulator

开源协议:

下载


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.

  1. require __DIR__ . '/vendor/autoload.php';
  2. use Grinderspro\DirectoryManipulator\DirectoryManipulator;
  3. (new DirectoryManipulator())->create();

Create many directories

  1. $dm = (new DirectoryManipulator())->location('/var/tmp/')->clear();
  2. for ($i=1; $i<=10; ++$i) {
  3. $dm->name('gm'.$i)->create();
  4. }

Create directory - “/var/tmp/{time()}”

  1. (new DirectoryManipulator())->location('/var/tmp/')->name()->create();

Create directory - “/var/tmp/grinderspro”

  1. (new DirectoryManipulator())->location('/var/tmp/')->name('grinderspro')->create();
  1. (new DirectoryManipulator())->location('/var/tmp/grinderspro')->create();
  1. if((new DirectoryManipulator())->location('/var/tmp/grinderspro')->create())
  2. return true;

To get the full path of the newly created directory, use the path() method without parameters.

  1. $dirName = (new DirectoryManipulator())->create('/var/tmp/')->name()->path();

Delete directories

  1. (new DirectoryManipulator())->location('/var/tmp/')->name('grinderspro')->delete();
  1. (new DirectoryManipulator())->location('/var/tmp/grinderspro')->delete();

Clear directory

  1. (new DirectoryManipulator())->location('/var/tmp/grinderspro')->clear();