lechimp-p/flightcontrol
最新稳定版本:1.0.0
Composer 安装命令:
composer require lechimp-p/flightcontrol
包简介
An interface for iterationr and recursion in directories over the leagues flysystem.
关键字:
README 文档
README
Flightcontrol
An interface for iteration and recursion over the Leagues flysystem.
This README.md is also a literate PHP-file.
This code is released under the GPLv3 License
Usage
Initialisation
The flightcontrol is initialized over a flysystem, e.g. as such:
<?php require_once("vendor/autoload.php"); use \League\Flysystem\Adapter\Local; use \League\Flysystem\Filesystem; use \Lechimp\Flightcontrol\Flightcontrol; $adapter = new Local(__DIR__, LOCK_EX, Local::SKIP_LINKS); $flysystem = new Filesystem($adapter); $flightcontrol = new Flightcontrol($flysystem); ?>
Make sure us use the Local::SKIP_LINKS-option when using flightcontrol, as it
will only handle files and directories.
Filesystem Objects
The flightcontrol can give you objects from the flystem:
<?php // base directory from the flysystem: $root = $flightcontrol->get("/"); assert($root !== null); assert($root instanceof \Lechimp\Flightcontrol\FSObject); // the tests directory: $tests = $flightcontrol->directory("/tests"); assert($tests !== null); assert($tests instanceof \Lechimp\Flightcontrol\Directory); // this file: $readme = $flightcontrol->file("/README.md"); assert($readme !== null); assert($readme instanceof \Lechimp\Flightcontrol\File); ?>
Note that you could use Flightcontrol::get to either get a directory or file,
and Flightcontrol::directory to get a directory or Flightcontrol::file to
get a file respectively. These getters will return null if there is no matching
object on the flysystem.
You could also use FSObject::toDirectory or FSObject::toFile to force an
FSObject to a file or directory, where you get a null if the object is not
what you want it to be.
Properties of Filesystem Object
The objects returned from the flightcontrol have different properties:
<?php // properties of every filesystem object: echo '$tests->path() == '.$tests->path()."\n"; assert($tests->path() == "/tests"); echo '$tests->name() == '.$tests->name()."\n"; assert($tests->name() == "tests"); // properties of files: echo '$readme->timestamp() == '.$readme->timestamp()."\n"; assert(is_string($readme->timestamp()) || is_int($readme->timestamp())); echo '$readme->mimetype() == '.$readme->mimetype()."\n"; assert($readme->mimetype() == "text/plain"); echo '$readme->content()'."\n"; assert(is_string($readme->content())); // properties of directories: $contents = $tests->contents(); echo '$tests->contents()'."\n"; assert(count($contents) > 0); assert($contents[0] instanceof \Lechimp\Flightcontrol\FSObject); ?>
File::content returns the content of the file as string. Directory::contents
gives you a list of filesystem objects in the directory.
统计信息
- 总下载量: 570
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2015-07-23