Leaf PHP

Directory
in package

Directory operations ---- This class provides a set of methods for local directory operations

Tags
since
3.0.0

Table of Contents

Properties

$dirCreateOptions  : mixed
$errorsArray  : mixed

Methods

copy()  : bool
Copy a directory
create()  : bool
Create a new directory
delete()  : bool
Delete a directory
dirs()  : array<string|int, mixed>|false
Get all directories in a directory
errors()  : array<string|int, mixed>
Return all errors that occurred during dir operations
exists()  : bool
Check if a directory exists
files()  : array<string|int, mixed>|false
Get all files in a directory
info()  : array<string|int, mixed>|bool
Get a summary of the dir information
isEmpty()  : bool
Check if a directory is empty
move()  : bool
Move a directory to a new location
read()  : array<string|int, mixed>|false
List all files and folders in a directory
size()  : number
Get the total size of a directory

Properties

$dirCreateOptions

protected static mixed $dirCreateOptions = ['mode' => 0777, 'rename' => false, 'recursive' => false, 'overwrite' => false]

$errorsArray

protected static mixed $errorsArray = []

Methods

copy()

Copy a directory

public static copy(string $source, string $destination[, array<string|int, mixed> $options = [] ]) : bool
Parameters
$source : string

The path of the dir to copy

$destination : string

The path to copy the dir to

$options : array<string|int, mixed> = []

Options for copying the dir

Return values
bool

create()

Create a new directory

public static create(string $dirPath[, array<string|int, mixed> $options = [] ]) : bool
Parameters
$dirPath : string

The path of the new directory

$options : array<string|int, mixed> = []

Options for creating the directory

Return values
bool

delete()

Delete a directory

public static delete(string $dirPath[, mixed $options = [] ]) : bool
Parameters
$dirPath : string

The path of the directory to delete

$options : mixed = []
Return values
bool

dirs()

Get all directories in a directory

public static dirs(string $dirPath) : array<string|int, mixed>|false
Parameters
$dirPath : string

The path of the dir to get the directories from

Return values
array<string|int, mixed>|false

errors()

Return all errors that occurred during dir operations

public static errors() : array<string|int, mixed>
Return values
array<string|int, mixed>

exists()

Check if a directory exists

public static exists(mixed $filePath) : bool
Parameters
$filePath : mixed
Return values
bool

files()

Get all files in a directory

public static files(string $dirPath) : array<string|int, mixed>|false
Parameters
$dirPath : string

The path of the dir to get the files from

Return values
array<string|int, mixed>|false

info()

Get a summary of the dir information

public static info(string $dirPath) : array<string|int, mixed>|bool
Parameters
$dirPath : string

The path of the dir to get the summary of

Return values
array<string|int, mixed>|bool

isEmpty()

Check if a directory is empty

public static isEmpty(string $dirPath) : bool
Parameters
$dirPath : string

The path of the directory to check

Return values
bool

move()

Move a directory to a new location

public static move(string $source, string $destination[, array<string|int, mixed> $options = [] ]) : bool
Parameters
$source : string

The path of the dir to move

$destination : string

The path to move the dir to

$options : array<string|int, mixed> = []

Options for moving the dir

Return values
bool

read()

List all files and folders in a directory

public static read(string $dirPath[, string|callable|null $pattern = null ]) : array<string|int, mixed>|false
Parameters
$dirPath : string
$pattern : string|callable|null = null
Return values
array<string|int, mixed>|false

size()

Get the total size of a directory

public static size(string $dirPath[, string $unit = 'byte' ]) : number
Parameters
$dirPath : string

The path of the directory to get the size of

$unit : string = 'byte'

The unit to return the size in

Return values
number

        
On this page

Search results