Repository navigation
CoreyFile
The CoreyFile class provides a robust, object-oriented interface for interacting with the server's filesystem. It abstracts standard PHP file functions into an intuitive API for reading, writing, editing, and retrieving metadata from files.
$file = new CoreyFile(array $userConfig);
userConfig
: An array of initial configuration options which seamlessly merges into the master CoreyPHP configuration array; alternatively, use setConfig() to update these values later.
The following methods are responsible for managing the state, metadata, and operations of the files and folders you interact with.
- filename - Sets the active file
- getDiagnostics - Environment and metrics
- getDirectory - Get a directory list
- getFileMetadata - Active file metadata
- getFiles - Get a list of files
- getFolders - Get a list of folders
- getParents - Get a list of parent directories
-
setPath - Set new path for file management
- setOutputPath - Set output path for file generation methods
The following methods are responsible for creating, editing, and modifying files and folders.
-
addFolder - Creates a folder
- removeFolder - Removes a folder
- renameFolder - Renames a folder
-
copyFile - Copies a file
- removeFile - Remove a file
- renameFile - Rename a file
- writeHtml - Creates a HTML file
- writeText - Creates a text file
The following methods facilitate format conversion.
- convertToBytes - Converts a human-readable file size string to bytes
- filesizeConvert - Converts a file size in bytes to a human-readable format
- permsConvert - Converts a decimal file permission integer
The following methods are used to generate and manipulate date and time variables.
- fileDate - Formats a Unix timestamp to a human-readable date format
The following methods are used to create images using the CoreyPHP Color Code Utility System.
- createJpg - Create JPG image file using CoreyPHP color code
- createPng - Create PNG image file using CoreyPHP color code
The following methods provide type-checking utilities to verify data integrity, ensuring that inputs conform to expected formats.
- isEmpty - Checks if folder is empty
The following methods help to generate standardized version strings for software releases, continuous integration build identifiers, and nightly builds.
- nightlyBuild - Calculates a nightly build version
- versionByDate - Generates a standard calendar version
- versionByTime - Generates a granular, build-level version
The following methods are either private or protected. They are documented here for developers who wish to extend this class.
- buildStaticPath - Creates nested static HTML relative directory paths
- processLocalAssets - Copies local assets in Static Site Generator
| Variable | Description | Example |
|---|---|---|
| file | The trimmed filename. | $file->file |
| bytes | The file size in bytes | $file->bytes |
| size | The file size converted. | $file->size |
| created | Date file was created. | $file->created |
| modified | Date file was last modified. | $file->modified |
| accessed | Date file was last accessed. | $file->accessed |
| path | The absolute directory path of the current working directory. | $file->path |
Refer to the Configuration Documentation section for a complete overview.
Home | CoreyFile