PHPackages                             effectra/fs - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. effectra/fs

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

effectra/fs
===========

The Effectra File System (fs) package.

v1.1.0(2y ago)2423MITPHP

Since May 25Pushed 2y agoCompare

[ Source](https://github.com/effectra/fs)[ Packagist](https://packagist.org/packages/effectra/fs)[ RSS](/packages/effectra-fs/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)DependenciesVersions (3)Used By (3)

Effectra FS - File Class
========================

[](#effectra-fs---file-class)

Effectra FS is a PHP library that offers a comprehensive set of classes for managing various aspects of the file system, including files, folders, JSON, CSV, and XML. The `File` class provided by Effectra FS provides static methods for handling file-related operations.

Installation
------------

[](#installation)

```
composer require effectra/fs
```

This command will download and install the Effectra FS library along with its dependencies into your project.

After the installation is complete, you can start using the library by including the necessary files and utilizing the `File` class as demonstrated in the previous readme file.

Class Reference
---------------

[](#class-reference)

### `File` Class

[](#file-class)

The `File` class provides static methods for managing files and performing file system operations.

#### Methods

[](#methods)

- `append($path, $data)`: Appends data to a file.
- `exists($path)`: Checks if a file exists.
- `delete($paths)`: Deletes one or multiple files.
- `put($path, $contents, $lock = false)`: Writes contents to a file.
- `replaceInFile($search, $replace, $path)`: Replaces occurrences of a string in a file.
- `clear($path)`: Clears the contents of a file.
- `getContent($path, ?int $length = null)`: Retrieves the contents of a file.
- `search($search, $path)`: Searches for a string in a file.
- `lastModified($path)`: Gets the last modified time of a file.
- `isExecutable($path)`: Checks if a file is executable.
- `isUploadedFile($path)`: Checks if a file is an uploaded file.
- `isReadable($path)`: Checks if a file is readable.
- `isWritable($path)`: Checks if a file is writable.
- `isFile($file)`: Checks if a path is a regular file.
- `glob($pattern, $flags = 0)`: Finds pathnames matching a pattern.
- `extension($path)`: Retrieves the file extension of a path.
- `type($path)`: Gets the file type of a path.
- `mimeType($path)`: Gets the MIME type of a file.
- `basename($path)`: Retrieves the basename of a path.
- `name($path)`: Retrieves the filename without extension of a path.
- `move($path, $target)`: Moves a file to a new location.
- `copy($path, $target)`: Copies a file to a new location.
- `size($path)`: Retrieves the file size.
- `require($path)`: Requires a PHP file.
- `requireOnce($path)`: Requires a PHP file once.
- `lines($path)`: Reads a file and returns an array of lines.
- `hash($path, $algorithm = 'md5')`: Calculates the hash value of a file.
- `replace($path, $content, $mode = null)`: Replaces the contents of a file.
- `chmod($path, $mode = null)`: Changes the mode of a file.
- `perms($path)`: Retrieves the permissions of a file.
- `fileATime($path)`: Gets the last accessed time of a file.
- `fileCTime($path)`: Gets the creation time of a file.
- `fileGroup($path)`: Gets the group ID of a file.
- `fileOwner($path)`: Gets the user ID of the owner of a file.

Usage
-----

[](#usage)

Once you have installed the Effectra FS library using Composer, you can start using the `File` class in your PHP code. Here's an example of how you can utilize some of the methods provided by the `File` class:

```
