lkt/file-reader
最新稳定版本:1.0.0
Composer 安装命令:
composer require lkt/file-reader
包简介
A simple file reader. PHP 8.1+
README 文档
README
This is a fork of chillerlan/php-filereader.
It was forked as soon I realize chillerlan/php-filereader last update was 4 years ago.
I like this package, and now supports php 8.1
chillerlan/php-filereader
A simple file/directory reader for all (well, most... ok. some.) of your file-reading needs.
Requirements
- PHP 8.1+
Documentation
Installation
requires composer
composer.json
(note: replace dev-master with a version boundary)
{
"require": {
"php": ">=7.2.0",
"chillerlan/database": "dev-master"
}
}
Manual installation
Download the desired version of the package from master or release and extract the contents to your project folder. After that:
- run
composer installto install the required dependencies and generate/vendor/autoload.php. - if you use a custom autoloader, point the namespace
chillerlan\Filereaderto the foldersrcof the package
Profit!
Usage
simple
You can just invoke one a FSDriverInterface and use it right away:
use chillerlan\Filereader\Drivers\DiskDriver; $filereader = new DiskDriver; $filereader->isDir('/some/path');
advanced
$directory = new Directory($filereader, '/some/path'); /** @var \chillerlan\Filereader\File $file */ foreach($directory->read() as $file){ echo $file->name; // ... }
API
FSDriverInterface methods
| method | return |
|---|---|
fileExists(string $path) |
bool |
isFile(string $path) |
bool |
fileContents(string $path) |
string |
getRequire(string $path) |
mixed |
deleteFile(string $path) |
bool |
copyFile(string $source, string $destination, bool $overwrite = true) |
bool |
isDir(string $path) |
bool |
makeDir(string $path) |
bool |
deleteDir(string $path) |
bool |
rename(string $oldname, string $newname, bool $overwrite = true) |
bool |
Directory public methods
| method | return |
|---|---|
__construct(FSDriverInterface $driver, string $path) |
- |
change(string $path) |
Directory |
read() |
array of File objects |
create(string $subdir = null) |
bool |
delete(string $subdir = null) |
bool |
rename(string $newname, bool $overwrite = true) |
Directory |
File public methods
| method | return |
|---|---|
__construct(FSDriverInterface $driver, Directory $directory, string $name) |
- |
exists() |
bool |
content() |
string |
getRequire() |
mixed |
copy(string $destination, bool $overwrite = true) |
bool |
rename(string $newname, bool $overwrite = true) |
File |
delete() |
bool |
common magic properties of Directory and File
| property | type | description |
|---|---|---|
$path |
string | the full path to the resource |
additional magic properties of File
| property | type | description |
|---|---|---|
$name |
string | the basename of the file |
$directory |
Directory |
the Directory which contains the file |
统计信息
- 总下载量: 162
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-12-16