All Projects → yiisoft → files

yiisoft / files

Licence: BSD-3-Clause License
Useful methods to manage files and directories

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to files

Voila
Voila is a domain-specific language launched through CLI tool for operating with files and directories in massive amounts in a fast & reliable way.
Stars: ✭ 78 (+188.89%)
Mutual labels:  files, directory, file, directories
PHP-FileUpload
Simple and convenient file uploads — secure by default
Stars: ✭ 53 (+96.3%)
Mutual labels:  files, filesystem, file
gtree
Output tree🌳 or Make directories📁 from #Markdown or Programmatically. Provide CLI, Golang library and Web (using #Wasm ).
Stars: ✭ 88 (+225.93%)
Mutual labels:  filesystem, directory, file
delete-empty
Recursively delete all empty folders in a directory and child directories.
Stars: ✭ 38 (+40.74%)
Mutual labels:  files, directory, directories
jquery.filebrowser
File browser jQuery plugin
Stars: ✭ 29 (+7.41%)
Mutual labels:  files, filesystem, directories
Fcfilemanager
iOS File Manager on top of NSFileManager for simplifying files management. 📂
Stars: ✭ 862 (+3092.59%)
Mutual labels:  files, directory, file
fsify
Convert an array of objects into a persistent or temporary directory structure.
Stars: ✭ 24 (-11.11%)
Mutual labels:  filesystem, directory, file
replace-in-files
Replace text in one or more files or globs.
Stars: ✭ 21 (-22.22%)
Mutual labels:  files, filesystem, file
Filegator
Powerful Multi-User File Manager
Stars: ✭ 587 (+2074.07%)
Mutual labels:  files, filesystem, file
Chonky
😸 A File Browser component for React.
Stars: ✭ 313 (+1059.26%)
Mutual labels:  files, filesystem, file
File Storage
File storage abstraction for Yii2
Stars: ✭ 116 (+329.63%)
Mutual labels:  files, filesystem, file
Copy Webpack Plugin
Copy files and directories with webpack
Stars: ✭ 2,679 (+9822.22%)
Mutual labels:  files, filesystem, file
log-target-file
Yii Logging Library - File Target
Stars: ✭ 19 (-29.63%)
Mutual labels:  file, yii3
Com2Kube
Web application that convert docker-compose files to kubernetes files
Stars: ✭ 26 (-3.7%)
Mutual labels:  files, file
file access
File.io for Web, Desktop and Mobile for Flutter
Stars: ✭ 59 (+118.52%)
Mutual labels:  files, file
txr
Send files super easily to other computers/servers using WebSockets.
Stars: ✭ 20 (-25.93%)
Mutual labels:  files, directories
lumen-file-manager
File manager module for the Lumen PHP framework.
Stars: ✭ 40 (+48.15%)
Mutual labels:  files, file
flutter file utils
Flutter package for managing files on Android
Stars: ✭ 35 (+29.63%)
Mutual labels:  filesystem, file
luufs
Lazy man's, user-mode union file system
Stars: ✭ 28 (+3.7%)
Mutual labels:  files, filesystem
nucked-truth-of-files
HollyJS Moscow
Stars: ✭ 14 (-48.15%)
Mutual labels:  files, filesystem

Yii Files


The package provides useful methods to manage files and directories.

Latest Stable Version Total Downloads Build Status Scrutinizer Code Quality Code Coverage Mutation testing badge static analysis type-coverage

Requirements

  • PHP 7.4 or higher.

Installation

The package could be installed with composer:

composer require yiisoft/files --prefer-dist

FileHelper usage

FileHelper provides static methods you can use for various filesystem-related operations.

Working with directories

Ensure a directory exists:

use \Yiisoft\Files\FileHelper;

$directory = '/path/to/dir';
FileHelper::ensureDirectory($directory);

Ensure a directory exists, and permission specified is set:

use \Yiisoft\Files\FileHelper;

$directory = '/path/to/dir';
FileHelper::ensureDirectory($directory, 0775);

Remove a directory:

use \Yiisoft\Files\FileHelper;

$directory = '/path/to/dir';
FileHelper::removeDirectory($directory);

Remove everything within a directory but not directory itself:

use \Yiisoft\Files\FileHelper;

$directory = '/path/to/dir';
FileHelper::clearDirectory($directory);

Check if directory is empty:

use \Yiisoft\Files\FileHelper;

$directory = '/path/to/dir';
FileHelper::isEmptyDirectory($directory);

Copy directory:

use \Yiisoft\Files\FileHelper;

$source = '/path/to/source';
$destination = '/path/to/destination';
FileHelper::copyDirectory($source, $destination);

Additional options could be specified as third argument such as filter or copyEmptyDirectories. Check method phpdoc for a full list of options.

Search

Searching for files:

use \Yiisoft\Files\FileHelper;
use Yiisoft\Files\PathMatcher\PathMatcher;

$files = FileHelper::findFiles('/path/to/where/to/search', [
    'filter' => (new PathMatcher())->only('**.png', '**.jpg')->except('**/logo.png'),
]);

Searching for directories:

use \Yiisoft\Files\FileHelper;
use Yiisoft\Files\PathMatcher\PathMatcher;

$directories = FileHelper::findDirectories('/path/to/where/to/search', [
    'filter' => (new PathMatcher())->except('**meta'),
]);

Other

Open a file. Same as PHP's fopen() but throwing exceptions.

use \Yiisoft\Files\FileHelper;

$handler = FileHelper::openFile('/path/to/file', 'rb');

Get last modified time for a directory or file:

use \Yiisoft\Files\FileHelper;

$directory = '/path/to/dir';
$time = FileHelper::lastModifiedTime($directory);

The method is different from PHP's filemtime() because it actually scans a directory and selects the largest modification time from all files.

Remove a file or symlink:

use \Yiisoft\Files\FileHelper;

$file = '/path/to/file.txt';
FileHelper::unlink($file);

Normalize a path:

use \Yiisoft\Files\FileHelper;

$path = '/home/samdark/./test/..///dev\yii/';
echo FileHelper::normalizePath($path);
// outputs:
// /home/samdark/dev/yii

Testing

Unit testing

The package is tested with PHPUnit. To run tests:

./vendor/bin/phpunit

Mutation testing

The package tests are checked with Infection mutation framework with Infection Static Analysis Plugin. To run it:

./vendor/bin/roave-infection-static-analysis-plugin

Static analysis

The code is statically analyzed with Psalm. To run static analysis:

./vendor/bin/psalm

License

The Yii Files is free software. It is released under the terms of the BSD License. Please see LICENSE for more information.

Maintained by Yii Software.

Support the project

Open Collective

Follow updates

Official website Twitter Telegram Facebook Slack

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].