• This repository has been archived on 09/Aug/2024
  • Stars
    star
    226
  • Rank 176,514 (Top 4 %)
  • Language
    PHP
  • License
    MIT License
  • Created about 7 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Microsoft Azure Blob Storage integration for Laravel's Storage API

DEPRECATION NOTICE

This package is dependent on Flysystem's Azure Blob Storage integration. The creator of that has announced that because Microsoft are dropping support for their PHP storage client, he will also be dropping Azure support from Flysystem in 2024.

As a result, there is no viable path for me to continue to maintain this package past that point. It will therefore be deprecated at the same time.

If you're currently using this package on a project, I suggest you begin considering alternatives to Azure that are officially supported by Laravel, such as Amazon S3.

laravel-azure-storage

CircleCI

Microsoft Azure Blob Storage integration for Laravel's Storage API.

This is a custom driver for Laravel's File Storage API, which is itself built on top of Flysystem 3. It uses Flysystem's own Azure blob storage adapter, and so can't easily add any more functionality than that has - indeed, adding that would be out of scope for the project.

Installation

Install the package using composer:

composer require matthewbdaly/laravel-azure-storage

Then add this to the disks section of config/filesystems.php:

        'azure' => [ // NB This need not be set to "azure", because it's just the name of the connection - feel free to call it what you want, or even set up multiple blobs with different names
            'driver'    => 'azure', // As this is the name of the driver, this MUST be set to "azure"
            'name'      => env('AZURE_STORAGE_NAME'),
            'key'       => env('AZURE_STORAGE_KEY'),
            'container' => env('AZURE_STORAGE_CONTAINER'),
            'url'       => env('AZURE_STORAGE_URL'),
            'prefix'    => null,
            'connection_string' => env('AZURE_STORAGE_CONNECTION_STRING') // optional, will override default endpoint builder 
        ],

Finally, add the fields AZURE_STORAGE_NAME, AZURE_STORAGE_KEY, AZURE_STORAGE_CONTAINER and AZURE_STORAGE_URL to your .env file with the appropriate credentials. The AZURE_STORAGE_URL field is optional, this allows you to set a custom URL to be returned from Storage::url(), if using the $root container the URL will be returned without the container path. A prefix can be optionally used. If it's not set, the container root is used. Then you can set the azure driver as either your default or cloud driver and use it to fetch and retrieve files as usual.

For details on how to use this driver, refer to the Laravel documentation on the file storage API.

Custom endpoints

The package supports using a custom endpoint, as in this example:

        'azure' => [
            'driver'    => 'azure',
            'name'      => env('AZURE_STORAGE_NAME'),
            'key'       => env('AZURE_STORAGE_KEY'),
            'container' => env('AZURE_STORAGE_CONTAINER'),
            'url'       => env('AZURE_STORAGE_URL'),
            'prefix'    => null,
            'connection_string' => null,
            'endpoint'  => env('AZURE_STORAGE_ENDPOINT'),
        ],

Then you can specify a suitable value for AZURE_STORAGE_ENDPOINT in your .env file as normal.

SAS token authentication

With SAS token authentication the endpoint is required. The value has the following format: https://[accountName].blob.core.windows.net

        'azure' => [
            'driver'    => 'azure',
            'sasToken'  => env('AZURE_STORAGE_SAS_TOKEN'),
            'container' => env('AZURE_STORAGE_CONTAINER'),
            'url'       => env('AZURE_STORAGE_URL'),
            'prefix'    => null,
            'endpoint'  => env('AZURE_STORAGE_ENDPOINT'),
        ],

Retries

The Azure Storage SDK ships a middleware to retry failed requests. To enable the retry middewalre, add a retry directive to the disk's configuration options.

        'azure' => [
            'driver'    => 'azure',
            // Other Disk Options...
            'retry'     => [
                'tries' => 3,                   // number of retries, default: 3
                'interval' => 500,              // wait interval in ms, default: 1000ms
                'increase' => 'exponential'     // how to increase the wait interval, options: linear, exponential, default: linear
            ]
        ],

Unsupported features

As this package uses the Flysystem Azure integration, it shares the following limitations with that:

  • Visibility setting or retrieving is not supported.
  • Mimetypes are always resolved, where others do not.
  • Directory creation is not supported in any way.

Support policy

This package is supported on the current Laravel LTS version, and any later versions. If you are using an older Laravel version, it may work, but I offer no guarantees, nor will I accept pull requests to add this support.

By extension, as the current Laravel LTS version required PHP 7.0 or greater, I don't test it against PHP < 7, nor will I accept any pull requests to add this support.

Can you add support for storage backend X?

No. This is exclusively for Azure Blob storage, and I am categorically not interested in expanding the scope of it to support other backends.

As long as Flysystem supports it, you can roll your own Laravel filesystem driver easily as described at https://laravel.com/docs/9.x/filesystem#custom-filesystems if you need to - this is the method I used to build this package.

More Repositories

1

laravel-etag-middleware

A Laravel middleware for adding ETags to HTTP requests to improve response times
PHP
61
star
2

django_tutorial_blog_ng

The source for the new version of my Django tutorial blog
Python
40
star
3

laravel-sms

SMS service provider for Laravel
PHP
35
star
4

artisan-standalone

Allows you to use Artisan outside of a Laravel install.
PHP
32
star
5

sms-client

A generic SMS client library. Supports multiple swappable drivers.
PHP
21
star
6

vagrant-php-dev-boilerplate

A boilerplate Vagrant configuration for PHP development
Shell
18
star
7

Django-Tutorial-Blog

A simple blogging engine written using Django for a tutorial on my website
Python
18
star
8

laravel-package-boilerplate

Boilerplate for Laravel packages
PHP
16
star
9

jquery.listfilter

A simple and fast jQuery plugin for creating a filter for an HTML list
JavaScript
13
star
10

twitter-stream

A simple Twitter stream viewer that uses Node.js, React.js and Redis
CSS
12
star
11

laravel-repositories

A base repository class and interface, together with a caching decorator. Extend them for use in your own projects
PHP
12
star
12

gigfinder

A web app for finding gigs
Python
10
star
13

laravel-comments

Comments package for Laravel
PHP
8
star
14

grunt-blogbuilder

A Grunt task for generating a static blog
JavaScript
8
star
15

babblr

A simple Node.js based chat server. Uses Redis's pub/sub support
JavaScript
7
star
16

Shortbread

A simple URL shortener. Implemented in Node.js, using Redis as the datastore
JavaScript
7
star
17

laravel-internal-requests

Make internal requests against your Laravel application
PHP
6
star
18

ernie

Simple dependency injection container, built to understand the concept better
PHP
6
star
19

generator-simple-static-blog

A Yeoman generator for building a simple static blog
JavaScript
6
star
20

letter-classifier

Proof of concept for a letter classifier in PHP. Uses Tesseract to extract the text and pass it through a machine learning library
PHP
6
star
21

laravel-dynamic-serving

Middleware for determining if user agent is mobile or not, and adding it to the session
PHP
5
star
22

generator-skellington

A Yeoman generator for a Skeleton web page, with automated FTP deployment
CSS
5
star
23

grunt-mini-static-blog

Grunt plugin for creating a static blog
JavaScript
5
star
24

abstract-or-final-sniff

PHP CodeSniffer sniff to find classes not declared as abstract or final
PHP
4
star
25

ansible-tasks

A collection of Ansible playbooks and roles I use
HTML
4
star
26

psalm-plugin-zendframework1

Psalm plugin for Zend 1
PHP
4
star
27

laravel-opensearch

OpenSearch implementation for Laravel
PHP
4
star
28

rabbitrabbitrabbit

A real-time guestbook apolication. Built with Node.js, MongoDB, Express.js and Socket.io on the server side, and Backbone on the client side.
JavaScript
3
star
29

vim-statamic-antlers

Vim syntax highlighting for Statamic Antlers templates
Vim Script
3
star
30

mynewanimalfriend-app

App for the My New Animal Friend tutorial
JavaScript
3
star
31

unframework

Unframework is not a framework. It's an opinionated collection of off-the-shelf PHP components and some very basic glue to stick them together for cases where you don't want to use a full framework
PHP
3
star
32

PushWooshPHPLibrary

A PHP library for sending push notifications via the Pushwoosh service
PHP
3
star
33

snippetr

A snippet-sharing application written with Django
Python
3
star
34

proper

Proper collections and strings for PHP
PHP
2
star
35

Steel-Age

A simple WordPress theme I'm working on
PHP
2
star
36

lightweight-laravel

Lightweight Laravel example
PHP
2
star
37

mynewanimalfriend-backend

Backend for the My New Animal Friend app built for a tutorial
PHP
2
star
38

react-todos

A simple todo list written to learn about React.js
JavaScript
2
star
39

laravel-bookmarks

Simple bookmark model for Laravel
PHP
2
star
40

postcode-client

Postcode lookup client
PHP
2
star
41

php-mvc-from-scratch

Build a PHP MVC application from scratch
2
star
42

oldsite

I'm a web developer in Norfolk. This is my blog...
HTML
2
star
43

My-vim-configuration

My personal Vim config files
Vim Script
2
star
44

laravel-admin

A generic admin interface for Laravel
PHP
2
star
45

statico

Statico flat file CMS
PHP
2
star
46

laravel-cart

Simple shopping cart implementation for Laravel. Loosely inspired by CodeIgniter's shopping cart.
PHP
2
star
47

matthewbdaly

Profile
1
star
48

ZendSearch

Fork of Zend Search
PHP
1
star
49

djumblr

Django tumblelog
Python
1
star
50

spectrum

A set of reusable React components, intended for Phonegap development
JavaScript
1
star
51

vim-filetype-settings

A set of filetype settings for Vim
Vim Script
1
star
52

react-kanban

A React-based Kanban board project
JavaScript
1
star
53

microblog

1
star
54

laravel-tags

Tags for Laravel models
PHP
1
star
55

gatsby-starter-netlify-cms

JavaScript
1
star
56

linklater

Linklater link storing service
PHP
1
star
57

harmony

Build Laravel API endpoints quickly and easily
PHP
1
star
58

Djibouti

A Django-powered blogging engine with Markdown and Pygments support
CSS
1
star
59

react-app-skeleton

A simple React app skeleton
JavaScript
1
star
60

gatsby-callback-paths

Use a callback to define paths in GatsbyJS
JavaScript
1
star
61

laravel-testing-recipes

1
star
62

laravel-postcodes

Laravel Postcode lookup integration
PHP
1
star
63

laravel-authority

Permissions package
PHP
1
star
64

matthewbdaly.github.io

TypeScript
1
star
65

personal-dashboard

A personal dashboard
JavaScript
1
star
66

laravel-golden-master-tests

A Laravel package allowing for easy golden master tests when writing better tests isn't practical
PHP
1
star
67

react-realtime-markdown-snippets

A simple Markdown snippet creator that uses React.js
JavaScript
1
star
68

laravel-flatpages

Laravel flat pages package. Inspired by Django's flatpages
PHP
1
star
69

snowpack-demo

Simple demo of Snowpack with React, Typescript and Tailwind set up
JavaScript
1
star