ajoy39 / laravel-storage-azure
为Laravel Storage提供的Azure Blob Storage驱动程序
v1.0.0
2020-09-09 03:39 UTC
Requires
Requires (Dev)
- orchestra/testbench: ^6.0.0
- phpunit/phpunit: ^9.0.0
Suggests
- league/flysystem-cached-adapter: For increased filesystem perfomance when using azure storage
- dev-master
- v1.0.0
- v0.2
- v0.1
- dev-dependabot/composer/orchestra/testbench-6.37.0
- dev-dependabot/composer/symfony/http-kernel-5.4.27
- dev-dependabot/composer/guzzlehttp/psr7-1.9.1
- dev-dependabot/composer/laravel/framework-8.83.27
- dev-dependabot/composer/guzzlehttp/guzzle-6.5.8
- dev-dependabot/composer/league/flysystem-1.1.4
This package is auto-updated.
Last update: 2024-09-25 06:11:18 UTC
README
本软件包提供了一个简单、即插即用的服务提供程序,用于使用Azure Blob Storage作为Laravel Storage服务的后端。
安装
composer require ajoy39/laravel-storage-azure
配置
设置连接时有两个选项,您可以使用Azure提供的连接字符串或单独输入值。
连接字符串方法
在config/filesystem.php中,将以下内容添加到存储驱动程序数组中
'azure' => [
'driver' => 'azure-blob-storage',
'connection_string' => env('AZURE_BLOB_STORAGE_CONNECTION_STRING'),
'container' => env('AZURE_BLOB_STORAGE_CONTAINER')
]
在您的环境文件中填写值
AZURE_BLOB_STORAGE_CONNECTION_STRING=
AZURE_BLOB_STORAGE_CONTAINER=
显式配置方法
在config/filesystem.php中,将以下内容添加到存储驱动程序数组中
'azure' => [
'driver' => 'azure-blob-storage',
'account_name' => env('AZURE_BLOB_STORAGE_ACCOUNT_NAME'),
'account_key' => env('AZURE_BLOB_STORAGE_ACCOUNT_KEY'),
'container' => env('AZURE_BLOB_STORAGE_CONTAINER')
]
然后,在您的.env文件或环境管理解决方案中填写环境变量
AZURE_BLOB_STORAGE_ACCOUNT_NAME=
AZURE_BLOB_STORAGE_ACCOUNT_KEY=
AZURE_BLOB_STORAGE_CONTAINER=
如果您使用Azure Government Cloud,则需要将端点后缀添加到配置数组和环境变量中。此步骤对于连接字符串方法不是必需的,因为连接字符串已定义了端点后缀。
'azure' => [
'driver' => 'azure-blob-storage',
'account_name' => env('AZURE_BLOB_STORAGE_ACCOUNT_NAME'),
'account_key' => env('AZURE_BLOB_STORAGE_ACCOUNT_KEY'),
'endpoint_suffix' => env('AZURE_BLOB_STORAGE_ENDPOINT_SUFFIX')
'container' => env('AZURE_BLOB_STORAGE_CONTAINER')
]
AZURE_BLOB_STORAGE_ACCOUNT_NAME=
AZURE_BLOB_STORAGE_ACCOUNT_KEY=
AZURE_BLOB_STORAGE_CONTAINER=
AZURE_BLOB_STORAGE_ENDPOINT_SUFFIX
使用方法
现在您可以直接使用Storage::disk('azure')
。如果您想将Azure设置为默认存储磁盘,只需设置FILESYSTEM_DRIVER环境变量即可。
FILESYSTEM_DRIVER=azure