mmieluch / laravel-vfs-provider by mmieluch

A Laravel service provider for Flysystem's wrapper around PHP-VFS.
18,102
4
0
Package Data
Maintainer Username: mmieluch
Maintainer Contact: michal.mieluch@bluefroglondon.com (Michał Mieluch)
Package Create Date: 2016-02-12
Package Last Update: 2019-09-19
Language: PHP
License: MIT
Last Refreshed: 2024-04-23 03:11:59
Package Statistics
Total Downloads: 18,102
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 4
Total Watchers: 0
Total Forks: 2
Total Open Issues: 1

laravel-vfs-provider

Latest Stable Version Total Downloads License

A service provider intended to use with Laravel 5.x for The League Flysystem's wrapper around PHP-VFS library.

Installation

  1. Update your project dependencies:

    composer require mmieluch/laravel-vfs-provider
    
  2. Register new service provider in config/app.php:

return [

    'providers' => [

        ...

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

    ],

];
  1. Update your config/filesystems.php file:
return [

    ...

    'disks' => [

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

    ],

];

Now you can start using your new driver, just as you'd use a local driver:


// 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');

For full set of instructions on how to use the Laravel filesystem service visit Laravel's official documentation

TODO

  • set up path prefix (configuration root), like in other drivers;
  • add tests.

Bugs? Suggestions?

Feel free to file an issue or submit a PR.

License

This package is open-sourced software licensed under the MIT license.