bhittani/filesystem
Composer 安装命令:
composer require bhittani/filesystem
包简介
Utilities for working with the filesystem.
关键字:
README 文档
README
Utilities for working with the filesystem in PHP.
Install
You may install this package using composer.
$ composer require bhittani/filesystem --prefer-dist
Usage
This packages offers some helpful utilities when working with the filesystem. It extends symfony/filesystem.
<?php require_once __DIR__ . '/vendor/autoload.php'; $fs = new \Bhittani\Filesystem\Filesystem; // Use the API calls as demonstrated below.
Each
Traverse over all the files (recursive) in a directory.
$fs->each('/path/to/a/directory', function (\SplFileInfo $splFileInfo) { // Do something... });
Inject
Inject a payload into a file or every file in a directory.
$fs->inject('/path/to/a/file/or/directory', [ 'foo' => 'bar', ]);
This will lazily find
[foo]in each file contents and replace it withbar.
A callback is also accepted as the payload which will receive the path to the current file.
Dump
Dump a file or directory with an optional payload.
$fs->dump('/path/to/a/dest/directory', '/path/to/a/src/directory', [ 'foo' => 'bar', ]);
If a callback is provided as the payload, it will receive the path to the current destination file.
Get Contents
Get the contents of a file with an optional payload.
$fs->getContents('/path/to/file', [ 'foo' => 'bar', ]);
Static Access
A StaticFilesystem class is available.
<?php require_once __DIR__ . '/vendor/autoload.php'; use Bhittani\Filesystem\StaticFilesystem; echo StaticFilesystem::getContents('/path/to/file');
Any of the public methods may be invoked by static access.
Changelog
Please see CHANGELOG for more information on what has changed.
Testing
git clone https://github.com/kamalkhan/filesystem cd filesystem composer install composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email shout@bhittani.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see the License File for more information.
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-10-14