mmieluch/laravel-vfs-provider

为 Flysystem 添加 PHP-VFS 库包装的 Laravel 服务提供者。

1.1.0 2019-09-19 21:10 UTC

This package is auto-updated.

Last update: 2024-09-20 07:56:33 UTC


README

Latest Stable Version Total Downloads License

一个旨在与 Laravel 5.x 一起使用的服务提供者,用于 The League Flysystem 的 PHP-VFS 库包装。

安装

  1. 更新项目依赖项

    composer require mmieluch/laravel-vfs-provider
  2. config/app.php 中注册新的服务提供者

return [

    'providers' => [

        ...

        /*
         * 3rd Party Service Providers
         */
        Mmieluch\LaravelVfsProvider\LaravelVfsServiceProvider::class,

    ],

];
  1. 更新你的 config/filesystems.php 文件
return [

    ...

    'disks' => [

      // This is just an example name, you can call your disk
      // however you want :)
      'virtual' => [
          'driver' => 'vfs',
      ],

    ],

];

现在你可以开始使用新的驱动器,就像使用 local 驱动器一样

// Get a handler for storage...
$storage = app('storage');
// Or, if your VFS disk is not a default one, you need to
// choose it from the pool of available disks.
$storage = app('storage')->disk('virtual');

// And you're ready to use your new virtual filesystem!
$storage->makeDirectory('foo');
$storage->put('foo/bar.txt', 'baz');

$storage->has('foo/bar.txt'); // Returns: true

echo $storage->get('/foo/bar.txt'); // Outputs: baz

// You'd like to use a facade? Why, go ahead!
Storage::put('test.txt', 'All about that bass');
// Again, if your virtual drive is not set as your default:
Storage::disk('virtual')->put('test.txt', 'No treble');

有关如何使用 Laravel 文件系统服务的完整说明,请参阅Laravel 官方文档

待办事项

  • 设置路径前缀(配置 root),就像在其他驱动器中一样;
  • 添加测试。

有错误?建议?

请随意提交问题或发送 PR。

许可证

本软件包是开源软件,根据MIT 许可证授权。