Leaf PHP

File
in package

File operations ---- This class provides a set of methods for local file operations

Tags
since
3.0.0

Table of Contents

Properties

$errorsArray  : mixed
$fileCreateOptions  : mixed

Methods

copy()  : bool
Copy a file
create()  : bool
Create a new file
delete()  : bool
Delete a file
errors()  : array<string|int, mixed>
Return all errors that occured during file operations
exists()  : bool
Check if a file exists
info()  : array<string|int, mixed>|bool
Get a summary of the file information
isEmpty()  : bool
Check if a file is empty
lastModified()  : string
Get the last modified date of a file
mimeType()  : string
Get the mime type of a file
move()  : bool
Move a file
read()  : mixed
Read the content of a file
size()  : number
Get the size of a file
systemType()  : string
Get the system file type of a file
type()  : string
Get the human readable file type of a file
upload()  : array<string|int, mixed>|bool
Upload a file
write()  : bool
Write content to an existing file

Properties

$errorsArray

protected static mixed $errorsArray = []

$fileCreateOptions

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

Methods

copy()

Copy a file

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

The path of the file to copy

$destination : string

The path to copy the file to

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

Options for copying the file

Return values
bool

create()

Create a new file

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

The path of the new file

$content : mixed = null

The content of the new file

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

Options for creating the file

Return values
bool

delete()

Delete a file

public static delete(string $filePath) : bool
Parameters
$filePath : string

The path of the file to delete

Return values
bool

errors()

Return all errors that occured during file operations

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

exists()

Check if a file exists

public static exists(string $filePath) : bool
Parameters
$filePath : string

The path of the file to check

Return values
bool

info()

Get a summary of the file information

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

The path of the file to get the summary of

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

isEmpty()

Check if a file is empty

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

The path of the file to check

Return values
bool

lastModified()

Get the last modified date of a file

public static lastModified(string $filePath) : string
Parameters
$filePath : string

The path of the file to get the last modified date of

Return values
string

mimeType()

Get the mime type of a file

public static mimeType(string $filePath) : string
Parameters
$filePath : string

The path of the file to get the mime type of

Return values
string

move()

Move a file

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

The path of the file to move

$destination : string

The path to move the file to

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

Options for moving the file

Return values
bool

read()

Read the content of a file

public static read(string $filePath) : mixed
Parameters
$filePath : string

The path of the file to read

size()

Get the size of a file

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

The path of the file to get the size of

$unit : string = 'byte'

The unit to return the size in

Return values
number

systemType()

Get the system file type of a file

public static systemType(string $filePath) : string
Parameters
$filePath : string

The path of the file to get the type of

Return values
string

type()

Get the human readable file type of a file

public static type(string $filePath) : string
Parameters
$filePath : string

The path of the file to get the type of

Return values
string

upload()

Upload a file

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

The path of the file to upload

$destination : string

The path to upload the file to

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

Options for uploading the file

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

write()

Write content to an existing file

public static write(string $filePath, mixed $content[, int $mode = 0 ]) : bool
Parameters
$filePath : string

The path of the file to write to

$content : mixed

The content to write to the file

$mode : int = 0

The mode to write the file in

Return values
bool

        
On this page

Search results