Helpers for working with files and directories.

Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the WireFileTools class also inherits all the methods and properties of: Wire.

Common / Advanced / Compiler

Show “$files”             Show Arguments        

Common

NameReturnSummary 
$files->chmod(string $path)
boolChange the read/write mode of a file or directory, consistent with ProcessWire's configuration settings
$files->copy(string $src, string $dst)
boolCopy all files recursively from one directory ($src) to another directory ($dst)
$files->find(string $path)
arrayFind all files in the given $path recursively, and return a flat array of all found filenames
$files->include(string $filename)
boolInclude a PHP file passing it all API variables and optionally your own specified variables
$files->includeOnce(string $filename)
boolSame as include() method except that file will not be executed if it as previously been included
$files->mkdir(string $path)
boolCreate a directory that is writable to ProcessWire and uses the defined $config chmod settings
$files->render(string $filename)
string or boolGiven a filename, render it as a ProcessWire template file
$files->rmdir(string $path)
boolRemove a directory and optionally everything within it (recursively)
$files->send(string $filename)
(nothing)Send the contents of the given filename to the current http connection
$files->unzip(string $file, string $dst)
arrayUnzips the given ZIP file to the destination directory
$files->zip(string $zipfile, $files)
arrayCreates a ZIP file

Advanced

NameReturnSummary 
$files->getNamespace(string $file)
stringGet the namespace used in the given .php or .module file
$files->tempDir($name)
WireTempDirReturn a new temporary directory/path ready to use for files

Additional methods and properties

In addition to the methods and properties above, WireFileTools also inherits the methods and properties of these classes:

API reference based on ProcessWire core version 3.0.66