php-extended/php-file-object

实现php-extended/php-file-interface接口库的库。

7.0.7 2024-07-31 13:52 UTC

README

实现php-extended/php-file-interface接口库的库。

coverage build status

安装

此库的安装通过composer完成,并且通过其自动加载器加载此库的所有类。

  • 他们的网站下载 composer.phar
  • 然后运行以下命令将此库作为依赖项安装
  • php composer.phar php-extended/php-file-object ^7

基本用法

使用时,您应该首先使用给定的绝对路径实例化一个文件系统,该文件系统将用于在(虚拟)文件系统中chroot给定的文件。然后,将使用文件系统对象的getFoldergetFile方法添加每个文件或文件夹。


use PhpExtended\Filesystem;

/* @var $fs \PhpExtended\File\FileSystem */
$fs = new Filesystem('/dev');	// absolute path from the real fs
/* @var $file \PhpExtended\File\File */
$file = $fs->getFile('random');	// path relative to the virtual fs
/* @var $stream \PhpExtened\File\FileStream */
$stream = $fs->getDataStream();
/* @var $data string */
$data = $stream->read(128);	// 128 bytes read from /dev/random

许可证

MIT (见许可证文件)。