LaravelFile

Summary

No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A
File
file.php
Package
Default
Class hierarchy
LaravelFile

Tags

None found

Methods

exists()

exists(string  $path) : boolean

Determine if a file exists.

Parameters

string $path

Returns

boolean

static

Tags

None found

get()

get(string  $path, mixed  $default = null) : string

Get the contents of a file.

// Get the contents of a file $contents = File::get(path('app').'routes'.EXT);

// Get the contents of a file or return a default value if it doesn't exist
$contents = File::get(path('app').'routes'.EXT, 'Default Value');

Parameters

string $path
mixed $default

Returns

string

static

Tags

None found

put()

put(string  $path, string  $data) : integer

Write to a file.

Parameters

string $path
string $data

Returns

integer

static

Tags

None found

append()

append(string  $path, string  $data) : integer

Append to a file.

Parameters

string $path
string $data

Returns

integer

static

Tags

None found

delete()

delete(string  $path) : boolean

Delete a file.

Parameters

string $path

Returns

boolean

static

Tags

None found

move()

move(string  $path, string  $target) : void

Move a file to a new location.

Parameters

string $path
string $target

static

Tags

None found

copy()

copy(string  $path, string  $target) : void

Copy a file to a new location.

Parameters

string $path
string $target

static

Tags

None found

extension()

extension(string  $path) : string

Extract the file extension from a file path.

Parameters

string $path

Returns

string

static

Tags

None found

type()

type(string  $path) : string

Get the file type of a given file.

Parameters

string $path

Returns

string

static

Tags

None found

size()

size(string  $path) : integer

Get the file size of a given file.

Parameters

string $path

Returns

integer

static

Tags

None found

modified()

modified(string  $path) : integer

Get the file's last modification time.

Parameters

string $path

Returns

integer

static

Tags

None found

mime()

mime(string  $extension, string  $default = 'application/octet-stream') : string

Get a file MIME type by extension.

// Determine the MIME type for the .tar extension $mime = File::mime('tar');

// Return a default value if the MIME can't be determined
$mime = File::mime('ext', 'application/octet-stream');

Parameters

string $extension
string $default

Returns

string

static

Tags

None found

is()

is(array|string  $extensions, string  $path) : boolean

Determine if a file is of a given type.

The Fileinfo PHP extension is used to determine the file's MIME type.

// Determine if a file is a JPG image $jpg = File::is('jpg', 'path/to/file.jpg');

// Determine if a file is one of a given list of types
$image = File::is(array('jpg', 'png', 'gif'), 'path/to/file');

Parameters

array|string $extensions
string $path

Returns

boolean

static

Tags

None found

mkdir()

mkdir(string  $path, integer  $chmod = 511) : void

Create a new directory.

Parameters

string $path
integer $chmod

static

Tags

None found

mvdir()

mvdir(string  $source, string  $destination, integer  $options = \FilesystemIterator::SKIP_DOTS) : void

Move a directory from one location to another.

Parameters

string $source
string $destination
integer $options

static

Tags

None found

cpdir()

cpdir(string  $source, string  $destination, boolean  $delete = false, integer  $options = \FilesystemIterator::SKIP_DOTS) : void

Recursively copy directory contents to another directory.

Parameters

string $source
string $destination
boolean $delete
integer $options

static

Tags

None found

rmdir()

rmdir(string  $directory, boolean  $preserve = false) : void

Recursively delete a directory.

Parameters

string $directory
boolean $preserve

static

Tags

None found

cleandir()

cleandir(string  $directory) : void

Empty the specified directory of all files and folders.

Parameters

string $directory

static

Tags

None found

latest()

latest(string  $directory, integer  $options = \FilesystemIterator::SKIP_DOTS) : \Laravel\SplFileInfo

Get the most recently modified file in a directory.

Parameters

string $directory
integer $options

Returns

LaravelSplFileInfo

static

Tags

None found