dspacelabs/filesystem

此包已被废弃,不再维护。作者建议使用 sonsofphp/filesystem 包。

PHP文件系统抽象

dev-master / 0.1.x-dev 2016-01-17 01:13 UTC

This package is not auto-updated.

Last update: 2023-11-22 13:41:44 UTC


README

Filesystem是围绕文件系统的一个通用的PHP包装器,允许您将文件存储在几乎任何地方。它解决的问题是在开发过程中,您希望在磁盘上存储东西,然后部署应用程序到Heroku,现在您必须处理检查您是否在localhost上或在Heroku实例上的混乱代码。

功能

  • 存储资产于
    • 本地磁盘
    • S3
    • 即将推出更多
  • 模拟文件系统用于测试
  • 支持使用psr/log包进行日志记录

安装

稳定版本: Packagist

开发版本: Packagist Pre Release

composer require "dspacelabs/filesystem:0.1@dev"

配置

每个适配器都有自己的配置,我已经在适配器文件中尽力记录。使用源代码。

使用

<?php

$adapter    = new \Dspacelabs\Component\Filesystem\Adapter\LocalAdapter('/tmp');
$filesystem = new \Dspacelabs\Component\Filesystem\Filesystem($adapter);

// Everything uses the `dspace` protocol, you can swap out different adapters
// but the protocol will always stay the same.
$handle = fopen('dspace://file.txt', 'w+');
fwrite($handle, 'testing');
fclose($handle);
$ cat /tmp/file.txt
testing

有关更多使用示例,请查看测试目录。

测试

只需运行phpunit即可运行所有测试。

phpunit

变更日志

查看CHANGELOG.md

许可

Packagist

查看LICENSE