hugsbrugs/php-filesystem

There is no license information available for the latest version (dev-master) of this package.

PHP File System Utilities

dev-master 2020-05-25 06:42 UTC

This package is auto-updated.

Last update: 2024-12-25 16:03:20 UTC


README

This librairy is a set of functions to ease filesystem operations and manipulations

Build Status

Coverage Status

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)

FileSystem::scandir_h($directory, $file_extension = null);

Remove files recursively in a directory

FileSystem::rrmdir($dir, $del_dir = TRUE);

Recursively copy files and folder to destination and creates directory structure if necessary

FileSystem::rcopy($source, $dest, $permissions = 0755);

Writes data in a file and creates directories if necessary

FileSystem::force_file_put_contents($filename, $data, $flags = 0, $context = null);

List files in a directory with options

FileSystem::list_dir($dir, $return_type = 'ALL', $return_format = 'FULL');

Get file last modification date in desired date format

FileSystem::file_last_mod($file_path, $date_format = 'Y-m-d H:i:s');

Get file size

FileSystem::file_size($FilePath);

Get bunch of informations about file list

FileSystem::get_file_list_infos($files);

Get a human readable file size

FileSystem::human_file_size($size, $unit = '');

Converts a file size in bytes in a human readable way

FileSystem::get_symbol_by_quantity($bytes);

Get a directory size

FileSystem::dir_size($directory);

Get disk usage

FileSystem::get_disk_usage($path);

Delete files in a directory older than a given date

FileSystem::remove_older_files($directory, $date_interval = 'P8D', $get_results = false, $test_mode = false);

Compares two files for eqality

FileSystem::are_files_equal($file_a, $file_b);

Get unix file permissions

FileSystem::unix_file_permissions($path);

Author

Hugo Maugey visit my website ;)