- Installation
- Introduction
- Functions
- file_get_directory
- file_get_extension
- file_get_name
- file_read
- file_create
- file_write
- file_append
- file_prepend
- file_delete
- file_move
- file_copy
- file_rename
- directory_get_name
- directory_get_parent
- directory_create
- directory_delete
- directory_exists
- directory_rename
- directory_move
- directory_copy
- directory_clear
- directory_list
- directory_list_files
- directory_list_directories
composer require weew/helpers-filesystem
This tiny library provides various helper functions to deal with files and directories in a concise and easy way.
Get name of the file's directory.
string file_get_directory(string $path)
Get name of the file's directory.
string file_get_extension(string $path)
Get name of the file's directory.
string file_get_name(string $path)
Read contents of a file.
mixed file_read(string $path)
Create a file and all necessary subdirectories.
bool file_create(string $path)
Write to a file.
bool file_write(string $path, string $content)
Append contents to the end of file.
bool file_append(string $path, string $content)
Prepend contents to the beginning of file.
bool file_prepend(string $path, string content)
Delete a file.
bool file_delete(string $path)
Move a file from one location to another and create all necessary subdirectories.
bool file_rename(string $oldPath, string $newPath)
Copy a file from one location to another and create all necessary subdirectories.
bool file_copy(string $oldPath, string $newPath)
Rename file at the given path.
bool file_rename(string $path, $newName)
Get name of the file's directory.
string directory_get_name(string $path)
Get path of the parent directory.
string directory_get_parent(string $path)
Create a directory and all subdirectories.
bool directory_create(string $path [, $mode = 0777])
Delete a directory and all of its files.
bool directory_delete(string $path)
Check if a directory exists.
bool directory_exists(string $path)
Rename a directory.
bool directory_rename(string $path, string $newName)
Move directory to the specified path.
bool directory_move(string $oldPath, string $newPath)
Copy a directory and all of its contents to the specified path and create all necessary subdirectories.
bool directory_copy(string $oldPath, string $newPath)
Delete all files and directories inside a directory.
directory_clear(string $path)
Return a list of files and directories. $absolute
indicates whether the paths should be relative or absolute.
string[] directory_list(string $path [, $absolute = false])
Return a list of files. $absolute
indicates whether the paths should be relative or absolute.
string[] directory_list_files(string $path [, $absolute = false])
Return a list of directories. $absolute
indicates whether the paths should be relative or absolute.
string[] directory_list_directories(string $path [, $absolute = false])