Azure File Storage filesystem driver for Laravel
academe/laravel-azure-file-storage-driver is a Laravel package for azure file storage filesystem driver for laravel.
It currently has 15 GitHub stars and 146.682 downloads on Packagist (latest version 1.0.1).
Install it with composer require academe/laravel-azure-file-storage-driver.
Discover more Laravel packages by academe
or browse all Laravel packages to compare alternatives.
Last updated
This package allows Microsoft Azure File Storage to be used as a filesystem in laravel 5 and 6.
composer require academe/laravel-azure-file-storage-driver
This package just extends the filesystem driver, and provides no additional services.
Add the following to your config/filesystems.php:
[
...
'disks' => [
...
// Name this disk for your application to reference.
'azure-file-storage' => [
// The driver provided by this package.
'driver' => 'azure-file-storage',
// Account credentials.
'storageAccount' => env('AZURE_FILE_STORAGE_ACCOUNT'),
'storageAccessKey' => env('AZURE_FILE_STORAGE_ACCESS_KEY'),
// The file share.
// This driver supports one file share at a time (you cannot
// copy or move files between shares natively).
'fileShareName' => env('AZURE_FILE_STORAGE_SHARE_NAME'),
// Optional settings
'disableRecursiveDelete' => false,
'driverOptions' => [],
'root' => 'root/directory', // Without leading '/'
],
],
];
If you want to use multiple Azure file storage shares, then create additional
entries in the disks array with the appropriate settings for each share.
An example list of environment variable entries can be found in .env.example.
You can add that to your .env file and add your credentials there.
See the Laravel documentation for general usage of a file system in Laravel. A simple example follows:
use Storage;
// List all files recursively from the root of the Azure share:
$files = Storage::disk('azure-file-storage')->listAll();
dump($files);
// Example:
// array:25 [â–¼
// 0 => "file1.txt"
// 1 => "foo/file2.txt"
// 2 => "foo/dee/dar/bigfile.txt"
// ]
PHPunit tests will work against any file storage share given
criteria set in .env based on .env.example.