MMO\core\files
MMO\core\files · 33 symbols · generated 5 Oct 2026
copy
files.php:497Copy a file or folder (recursively), returning the number of files actually copied.
- Namespace
MMO\core\files
| $from | string | the source file/folder |
| $to | string | the destination |
| $inc = null | null | string | a regular expression to select the files to copy |
| $exc = null | null | string | a regular expression to exclude the files from being copied |
| returns | int | the number of files copied |
Call graph
Uses (1)
createDir
files.php:112Create a folder (recursively) if it does not exist.
- Namespace
MMO\core\files
| $dir | string | the folder path |
| $perms = null | null | int | the permission to give to the folder. if null, will use its parent permission. |
| returns | bool | true if the folder is created, false if the folder already exists. |
Call graph
csv
files.php:758Read and decode a CSV file (a UTF-8 BOM, if present, is stripped first). csvDecode().
- Namespace
MMO\core\files
| $resource | the filename, or an open handle on the file | |
| $keys = true | array | bool | if true, the first row is used as column names for every other row; if an array, used directly as column names (every row, including the first, is then data) |
| $separator = ';' | string | the field delimiter |
| $enclosure = '"' | string | the field quoting character |
| $escape = '\\' | string | the escape character |
| $lineSep = MMO\core\files\PHP_EOL | null | string | the line separator |
| returns | array |
Call graph
Used by (1)
dataURI
files.php:686Encode a file as a data: URI (its content, base64-encoded, with its detected mime type), ready to use directly as e.g. an <img src="...">.
- Namespace
MMO\core\files
Call graph
Uses (1)
dataURIToFile
files.php:716Reverse of dataURI(): decode a data: URI and write its content to $filename.
- Namespace
MMO\core\files
| $filename | string | |
| $data | string | a full data:mime/type;base64,... URI |
| returns | string | the mime type extracted from $data |
| throws | if $data isn't a base64 data URI |
Call graph
Uses (1)
Used by (1)
delete
files.php:544Recursively delete a file or folder. To inspect each individual path as it's deleted, use loopDelete() directly.
- Namespace
MMO\core\files
| $path | string | the file/folder to delete |
| $inc = null | null | string | a regular expression to select which entries to delete |
| $exc = null | null | string | a regular expression to exclude entries from being deleted |
| returns | void |
exists
files.php:578Test if a local file, or a remote url (via a curl HEAD request), exists/is reachable.
- Namespace
MMO\core\files
Call graph
filename
files.php:266Get the underlying filename (for a stream) or command (for a process) of a resource.
- Namespace
MMO\core\files
| $var | a stream or process resource | |
| returns | false if $var isn't a stream/process resource, or has no known uri/command |
Call graph
Used by (1)
get
files.php:357Read the content of a file (given as a filename, read directly) or an already-open stream resource.
- Namespace
MMO\core\files
| $stream | a filename, or an open stream resource | |
| $maxlen = null | null | int | maximum number of bytes to read. null for everything. |
| $offset = 0 | int | the offset to start reading from |
| returns | string | |
| throws | if $stream isn't readable |
Call graph
Used by (17)
- Application::getWorkers
- Cron::reload
- ImportSocket::run
- TestRunner::getSuites
- TestRunner::run
- MCPController::mcpResourcesRead
- MCPController::promptSkill
- MCPController::skillPrompts
- MCPController::symbolDocumentation
- MCPController::toolSearchDocumentation
- csv
- dataURI
- json
- XmlNodes::FromFile
- Mail::DKIMSign
- Mail::send
- Request::Server
image
files.php:697Load an image file (jpeg/png/gif) as a GD image resource/object.
- Namespace
MMO\core\files
isLocal
files.php:563Tells if a uri refers to the local filesystem: no authority at all (a plain path), or a file:///phar:// scheme. Determines whether exists()/mtime() use plain filesystem calls or a curl HEAD request.
- Namespace
MMO\core\files
Call graph
Used by (3)
isMoreRecent
files.php:640Tells if a file was modified after $time -- or, for a folder (or an already-obtained loopFolder() generator), if ANY file under it was.
- Namespace
MMO\core\files
| $filename | Generator | string | a filename, or a generator of files (e.g. from loopFolder()) |
| $time | int | a unix timestamp to compare against |
| $inc = null | null | string | a regular expression of files to include (only used when $filename is a folder) |
| $exc = null | null | string | a regular expression of files to exclude (only used when $filename is a folder) |
| returns | bool | false if $filename (a single file) doesn't exist |
Call graph
Uses (1)
Used by (1)
json
files.php:738Read and decode a JSON file (jsonDecode() for $asArray/$vars/$cleanUp).
- Namespace
MMO\core\files
| $resource | the filename, or an open handle on the file | |
| $asArray = true | bool | if true, a JSON object decodes to a plain PHP array instead of stdClass |
| $vars = null | null | array | variables to substitute into the JSON before decoding it (a light templating step) |
| $cleanUp = true | bool | if true, tolerate trailing commas and line/block comments (non-standard JSON, not natively supported by PHP) |
| returns | mixed | |
| throws | if the file's content isn't valid (post-cleanup) JSON |
loopCopy
files.php:467Recursively copy a file or folder, yielding each individual file as it's copied (a folder itself isn't yielded, only the files under it -- but it IS created, even if empty).
- Namespace
MMO\core\files
| $from | string | the source file/folder |
| $to | string | the destination |
| $inc = null | null | string | a regular expression to select the files to copy (loopFolder()) |
| $exc = null | null | string | a regular expression to exclude files from being copied (loopFolder()) |
| returns | string> yields sourceFile => destFile | |
| throws | if $from doesn't exist | |
| throws | if a copy fails |
Call graph
Uses (3)
loopDelete
files.php:516Recursively delete a file or folder (depth-first: a folder's contents are deleted before the folder itself), yielding the path of each thing actually removed as it's removed.
- Namespace
MMO\core\files
| $path | string | the file/folder to delete |
| $inc = null | null | string | a regular expression to select which entries to delete (loopFolder()) |
| $exc = null | null | string | a regular expression to exclude entries from being deleted (loopFolder()) |
| returns | Generator | yields each deleted path |
| throws | if a delete fails |
Call graph
Uses (2)
Used by (2)
loopFolder
files.php:160Lazily list the entries of a folder (files AND subfolders, each yielded individually -- a subfolder is yielded itself, in addition to whatever's recursed into it).
- Namespace
MMO\core\files
| $folder | string | the folder's filename, optionally ending in a glob pattern |
| $recursive = true | int | bool | if true, recurse into every subfolder; if an int, the remaining recursion depth (0 = don't recurse further) |
| $inc = null | null | string | a regex the entry's path (relative to $folder) must match to be yielded (null = include everything) |
| $exc = null | null | string | a regex that excludes a matching entry (and, if it's a folder, everything under it) entirely |
| $_path = '' | string | internal: the current path prefix during recursion. Leave at the default. |
| returns | Generator | string> yields relative path => absolute path |
| throws | if $inc/$exc isn't a valid regex | |
| throws | if $folder doesn't exist (and isn't a resolvable glob) |
move
files.php:664Move file to new destination
- Namespace
MMO\core\files
| $from | string | |
| $to | string | |
| $overwrite = false | bool | if false (default), an existing $to throws instead of being overwritten |
| returns | void | |
| throws | if $from doesn't exist | |
| throws | if $to already exists and either $overwrite is false or $to isn't writable | |
| throws | if the move itself fails |
Call graph
Uses (1)
mtime
files.php:603Get a file/url's last-modified time, locally via \filemtime() or remotely via a curl HEAD request.
- Namespace
MMO\core\files
| $url | string | |
| returns | null | int | a unix timestamp, or null if $url doesn't exist / isn't reachable / doesn't report a filetime |
name
files.php:239Get a short, human-readable identifier for a stream or process resource (for logging/debugging).
- Namespace
MMO\core\files
| $var | a stream or process resource | |
| returns | [type[:mode-or-pid]]uri-or-command, or [unknown]unknown ressource for anything else |
Call graph
Used by (2)
open
files.php:316Open a file and return the resulting stream resource, translating the STREAM_* flag bitmask into the right \fopen() mode (always append-mode when writing, so an existing file's content is preserved unless STREAM_CLEAR is also set -- write() which does the truncation).
- Namespace
MMO\core\files
| $filename | string | |
| $flags = MMO\core\files\STREAM_READ | int | a bitmask of STREAM_READ/STREAM_WRITE/STREAM_CLEAR/STREAM_CREATE_FOLDER/STREAM_BINARY |
| returns | ||
| throws | if the file cannot be opened (e.g. the target isn't writable) |
Call graph
package
files.php:821Package a list of files into a phar package WARNING: when creating a PharData (no stub), the filename MUST NOT have .phar in the extension. Else php throws an Exception.
- Namespace
MMO\core\files
| $filename | string | the phar archive's filename |
| $files | array | the files to add as localname => content content can be : - a filename - a directory. In this case localname MUST be the relative path contained in the directory to use in the phar: example: src/files => /home/mmo/src/files - a direct string if it starts with =, - a resource (fopen()), - a Traversable (DirectoryIterator) |
| $stub | array | string | null | the stub to use depending on the PHP_SAPI constant if it is a simple string, it is used for all. else it has to be an array[regex => name] where regex is used to test PHP_SAPI (* for any) name is the local filename of the file in the phar archive |
| $alias = null | null | string | the local phar alias to use to call flux operation on the archive. by default the basename of the archive. |
| $compression = Phar::NONE | int | a \Phar::* compression constant (e.g. \Phar::GZ, \Phar::BZ2) |
| returns | void | |
| throws | if phar.readonly is enabled in php.ini, or a file/folder to remove/add fails |
perms
files.php:59Get a file/folder's permissions formatted like unix ls -l (e.g. 'drwxr-xr-x').
- Namespace
MMO\core\files
Call graph
Uses (1)
Used by (3)
permsText
files.php:70Format a raw \fileperms()-style integer as a unix ls -l permission string.
- Namespace
MMO\core\files
put
files.php:432Same as write(), but always appends and creates any missing parent folder (STREAM_PUT = write + create folder).
- Namespace
MMO\core\files
| $stream | ||
| $text | string | |
| returns |
Call graph
Uses (1)
Used by (1)
rootFolder
files.php:211Get the deepest common ancestor folder shared by a list of filenames.
- Namespace
MMO\core\files
| $files | array | the files (at least one; absolute paths) |
| returns | string | ends with a trailing '/'. '/' itself if the files share no common folder beyond the filesystem root. |
scanFolder
files.php:199Same as loopFolder(), but eagerly collects the results into an array, naturally case-insensitively sorted and then REVERSED (so entries come back in descending natural order).
- Namespace
MMO\core\files
| $folder | string | |
| $recursive = true | int | bool | |
| $inc = null | null | string | |
| $exc = null | null | string | |
| returns | array | relative path => absolute path, descending natural order |
Call graph
Uses (2)
Used by (1)
set
files.php:421Same as write(), but always replaces the stream's entire existing content (STREAM_SET = write + clear).
- Namespace
MMO\core\files
| $stream | ||
| $text | string | |
| returns |
Call graph
size
files.php:445Format a byte count as a human-readable size, with French unit abbreviations (o/ko/Mo/Go/To).
- Namespace
MMO\core\files
| $bytes | string | int | an int byte count, or a filename to \filesize() first |
| $decimals = 2 | int | number of decimals |
| returns | string |
sort
files.php:135Sort a list of filenames "naturally" (so 'file2' sorts before 'file10' -- strnatcmp()).
- Namespace
MMO\core\files
| $files | ||
| returns | array | the same array, sorted (also returned for convenience/chaining) |
temporaryFilename
files.php:287Create an empty, uniquely-named temporary file (in the {tmp} path alias) and return its filename.
- Namespace
MMO\core\files
| $prefix = '' | string | a prefix to use for the filename |
| returns | the filename | |
| throws | if the file could not be created |
Call graph
temporaryFolder
files.php:299Create an empty, uniquely-named temporary FOLDER (in the {tmp} path alias) and return its filename.
- Namespace
MMO\core\files
| $prefix = '' | string | a prefix to use for the folder's name |
| returns | the folder's filename | |
| throws | if the folder was not created |
Call graph
Uses (2)
Used by (1)
write
files.php:383Write $text to a stream.
- Namespace
MMO\core\files
| $stream | ||
| $text | string | |
| $flags = MMO\core\files\STREAM_WRITE | int | a bitmask of STREAM_* const, only relevant when $stream is a filename (open()) |
| returns | ||
| throws | if $stream is neither a string nor a resource | |
| throws | on a write error |
Call graph
Uses (1)
zip
files.php:773Open a zip archive, throwing a descriptive exception (rather than returning an error code) on failure.
- Namespace
MMO\core\files
| $filename | string | |
| $flags | int | a bitmask of \ZipArchive::* open flags (e.g. \ZipArchive::CREATE) |
| returns | ZipArchive | |
| throws | if the archive can't be opened |