Remove a directory and optionally everything within it (recursively)
rmdir() function, this method provides a recursive option, which can be enabled by specifying true for the
$recursive argument. You should be careful with this option, as it can easily wipe out an entire directory tree in a flash.
Note that the $options argument was added in 3.0.118.
// Remove directory /site/assets/cache/foo-bar/ and everything in it $files->rmdir($config->paths->cache . 'foo-bar/', true); // Remove directory after ensuring $pathname is somewhere within /site/assets/ $files->rmdir($pathname, true, [ 'limitPath' => $config->paths->assets ]);
// basic usage $bool = $files->rmdir(string $path); // usage with all arguments $bool = $files->rmdir(string $path, bool $recursive = false, $options = );
Path/directory you want to remove
If set to true, all files and directories in $path will be recursively removed as well (default=false).
|array, bool, string|
Optional settings to adjust behavior or (bool|string) for limitPath option:
True on success, false on failure
API reference based on ProcessWire core version 3.0.228