dnj/filesystem
最新稳定版本:1.0.1
Composer 安装命令:
composer require dnj/filesystem
包简介
The Filesystem component provides basic utilities for the filesystem.
README 文档
README
The Filesystem component provides basic utilities for the filesystem and the start point of creating any filesystem
Introduction
This is a repository intended to serve as a starting point if you want to bootstrap a filesystem in PHP.
It could be useful if you want to implement a filesystem. The idea is that you don't have to worry about the basic structure of a filesystem.
We
Just implement this contracts and have your own filesystem!
We have to
- Latest versions of PHP and PHPUnit
- Best practices applied:
README.md(badges included)LICENSEcomposer.jsonphpunit.xml.gitignore
- Some useful resources to start coding
How To Start
First, You should decide what kind of filesystem you decide to create, Like: Local, TMP, S3, FTP or any file system you decide to create.
Note: we implement some filesystems that you can use them:
GitHub: All DNJ implemented filesystems
Create new project and require dnj/filesystem , so run:
composer require dnj/filesystem
Then, You should implement two interface, IDirectory and IFile
Note: The above interfaces is extended from See: INode
INode methods:
getBasename(): stringgetDirname(): stringgetPath(): stringgetRelativePath(IDirectory $base): stringexists(): boolgetDirectory(): IDirectorydelete(): voidrename(string $newName): void
IDirectory methods:
files(bool $recursively): Iterator<IFile|IDirectory>items(bool $recursively): Iterator<IFile>directories(bool $recursively): Iterator<IDirectory>make(bool $recursively): voidsize(bool $recursively): intmove(IDirectory $dest): voidfile(string $name): IFiledirectory(string $name): IDirectoryisEmpty(): boolcopyTo(IDirectory $dest): voidcopyFrom(IDirectory $source): void
IFile methods:
copyTo(IFile $dest): voidcopyFrom(IFile $source): voidmove(IFile $dest): voidread(int $length = 0): stringwrite(string $data): voidsize(): intgetExtension(): stringisEmpty(): boolmd5(bool $raw): stringsha1(bool $raw): string
Helpful resources
We implement some parts of the above interfaces that you can use them:
Directory Abstract: Directory
File Abstract: File
Node Abstract: Node
Example implementation:
Directory:
<?php namespace YOUR_NAMESPACE\YOUR_FILESYSTEM; use dnj\Filesystem\Directory as DirectoryAbstract; class Directory extends DirectoryAbstract { public function make(bool $recursively = true): void { ... } . . . }
File:
namespace YOUR_NAMESPACE\YOUR_FILESYSTEM; use dnj\Filesystem\File as FileAbstract; class Directory extends FileAbstract { public function write(string $data): void { ... } public function read(int $length = 0): string { ... } . . . }
DNJ implemented filesystems:
You can find all implemented filesystems by DNJ by following GitHub
Local FileSystem By DNJ: Github Repository
Temporary FileSystem By DNJ: Github Repository
S3 FileSystem By DNJ: Github Repository
More resources
PHP 8
PHPUnit
About
We'll try to maintain this project as simple as possible, but Pull Requests are welcomed!
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 1.88k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 7
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-09-26