Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save arcanoix/f755ca00f0b315fb4f74037d78e15977 to your computer and use it in GitHub Desktop.
Save arcanoix/f755ca00f0b315fb4f74037d78e15977 to your computer and use it in GitHub Desktop.
// how to write content to a file
$content = 'File content ...';
Storage::put( 'myfile.txt', $content );
// how to read content from a file
$content = Storage::get( 'myfile.txt' );
// how to delete a file
Storage::delete( 'myfile.txt' );
// how to append content to a file
$append = 'Appending text...';
Storage::append( 'myfile.txt', $append );
// how to prepend content to a file
$prepend = 'Prepended text...';
Storage::prepend( 'myfile.txt', $prepend );
// how to create a directory
$directory = '/path/to/dir';
Storage::makeDirectory($directory);
// how to delete a directory
$directory = '/path/to/dir';
Storage::deleteDirectory($directory);
// how to copy a file to another location
Storage::copy('myfile.txt', 'myfile_copy.txt');
// how to move a file somewhere else
Storage::move('old/myfile.txt', 'new/myfile.txt');
// how to check if a file exist
$exists = Storage::exists('myfile.txt');
// how to get size of a file
$size = Storage::size('myfile.txt');
// how to check when a file was last modified
$time = Storage::lastModified('myfile.txt');
// how to get all files in a directory
$directory = '/path/to/dir';
$files = Storage::files($directory);
// how to get all files & directories in a parent directory
$directory = '/path/to/dir';
$files = Storage::allFiles($directory);
// how to get all directories in a parent directory
$directory = '/path/to/dir';
$directories = Storage::directories($directory);
// how to recursively get all directories in a parent directory
$directory = '/path/to/dir';
$directories = Storage::allDirectories($directory);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment