List files and directories from a specified directory.
Parameters
Returns
Example
// List files from '/' and return the list as absolute path
$files = File::ls('/', true);
// List files from home directory and exclude block files, directories and hidden files
$files = File::ls('~', false, File::EXCLUDE_BLOCK | File::EXCLUDE_DIRECTORIES | File::EXCLUDE_HIDDEN);
// List directories recursively
$files = File::ls('~', false, File::EXCLUDE_FILES | FILE::LIST_RECURSIVE);
Check if file or directory exists. This method allows to search files inside different scopes (Inside or Outside the generated PHAR).
Parameters
Returns
Example
// Check if file exists inside project or PHAR
File::exists($filename, File::SCOPE_LOCAL);
// Check if file exists outside the project or PHAR
File::exists($filename, File::SCOPE_EXTERNAL);
Returns the executables owner home directory
Returns
Example
File::home();
Copy a file, or recursively copy a folder and its contents.
Parameters
Returns
Example
// Copy recursively an entire directory and exclude the hidden files
File::xcopy($source_directory, $remote_directory, File::EXCLUDE_HIDDEN);
// Copy recursively everything inside the source directory
File::xcopy($source_directory . '/*', $remote_directory);
Delete a directory recursively
Take care when you this method is used, you can delete files by accident.
Parameters
Returns