https://github.com/hugsbrugs/php-filesystem
PHP Filesystem utilities
https://github.com/hugsbrugs/php-filesystem
filesystem php php-filesystem
Last synced: 7 months ago
JSON representation
PHP Filesystem utilities
- Host: GitHub
- URL: https://github.com/hugsbrugs/php-filesystem
- Owner: hugsbrugs
- Created: 2017-03-10T10:16:15.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2020-05-25T06:43:10.000Z (about 6 years ago)
- Last Synced: 2025-02-21T13:40:23.153Z (over 1 year ago)
- Topics: filesystem, php, php-filesystem
- Language: PHP
- Homepage:
- Size: 1.7 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# php-filesystem
This librairy is a set of functions to ease filesystem operations and manipulations
[](https://travis-ci.org/hugsbrugs/php-filesystem)
[](https://coveralls.io/github/hugsbrugs/php-filesystem?branch=master)
## Install
Install package with composer
```
composer require hugsbrugs/php-filesystem
```
In your PHP code, load librairy
```
require_once __DIR__ . '/../vendor/autoload.php';
use Hug\FileSystem\FileSystem as FileSystem;
```
## Usage
List files in a directory optionnaly filter by extension (. and .. are removed from response)
```php
FileSystem::scandir_h($directory, $file_extension = null);
```
Remove files recursively in a directory
```php
FileSystem::rrmdir($dir, $del_dir = TRUE);
```
Recursively copy files and folder to destination and creates directory structure if necessary
```php
FileSystem::rcopy($source, $dest, $permissions = 0755);
```
Writes data in a file and creates directories if necessary
```php
FileSystem::force_file_put_contents($filename, $data, $flags = 0, $context = null);
```
List files in a directory with options
```php
FileSystem::list_dir($dir, $return_type = 'ALL', $return_format = 'FULL');
```
Get file last modification date in desired date format
```php
FileSystem::file_last_mod($file_path, $date_format = 'Y-m-d H:i:s');
```
Get file size
```php
FileSystem::file_size($FilePath);
```
Get bunch of informations about file list
```php
FileSystem::get_file_list_infos($files);
```
Get a human readable file size
```php
FileSystem::human_file_size($size, $unit = '');
```
Converts a file size in bytes in a human readable way
```php
FileSystem::get_symbol_by_quantity($bytes);
```
Get a directory size
```php
FileSystem::dir_size($directory);
```
Get disk usage
```php
FileSystem::get_disk_usage($path);
```
Delete files in a directory older than a given date
```php
FileSystem::remove_older_files($directory, $date_interval = 'P8D', $get_results = false, $test_mode = false);
```
Compares two files for eqality
```php
FileSystem::are_files_equal($file_a, $file_b);
```
Get unix file permissions
```php
FileSystem::unix_file_permissions($path);
```
## Author
Hugo Maugey [visit my website ;)](https://hugo.maugey.fr)