PHPackages                             bornmt/azure-blob-url-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. bornmt/azure-blob-url-generator

ActiveLibrary[File &amp; Storage](/categories/file-storage)

bornmt/azure-blob-url-generator
===============================

Azure Blob SAS URL generator for Laravel and Spatie MediaLibrary

1.0.0(3mo ago)058↓50%MITPHPPHP ^8.2

Since Feb 5Pushed 3mo agoCompare

[ Source](https://github.com/Born-MT/azure-blob-url-generator)[ Packagist](https://packagist.org/packages/bornmt/azure-blob-url-generator)[ RSS](/packages/bornmt-azure-blob-url-generator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Azure Blob URL Generator
========================

[](#azure-blob-url-generator)

A Laravel package that provides Azure Blob Storage URL generation with SAS (Shared Access Signature) tokens for [Spatie Laravel Media Library](https://spatie.be/docs/laravel-medialibrary).

This package extends Spatie's default URL generator to produce Azure Blob Storage URLs with SAS token authentication, enabling secure access to media files stored in Azure Blob Storage.

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Laravel (with Illuminate Support)
- [spatie/laravel-medialibrary](https://github.com/spatie/laravel-medialibrary) ^11.17
- [azure-oss/storage-blob-laravel](https://github.com/Azure-OSS/azure-storage-php-adapter-laravel) ^1.4

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require bornmt/azure-blob-url-generator
```

### Register the Service Provider

[](#register-the-service-provider)

If you're using Laravel 11+, the service provider may be auto-discovered. Otherwise, add it to the `providers` array in `config/app.php`:

```
'providers' => [
    // ...
    BornMT\AzureBlobUrlGenerator\UrlGeneratorServiceProvider::class,
],
```

Configuration
-------------

[](#configuration)

### 1. Environment Variables

[](#1-environment-variables)

Add the following variables to your `.env` file:

```
AZURE_STORAGE_ENDPOINT=https://yourstorageaccount.blob.core.windows.net
AZURE_STORAGE_CONTAINER=your-container-name
AZURE_STORAGE_SAS_TOKEN=sv=2021-06-08&ss=b&srt=sco&sp=rl&se=...
```

VariableDescription`AZURE_STORAGE_ENDPOINT`The full URL of your Azure Storage account (e.g., `https://mystorageaccount.blob.core.windows.net`)`AZURE_STORAGE_CONTAINER`The name of the blob container where media files are stored`AZURE_STORAGE_SAS_TOKEN`The SAS token string (without the leading `?`) for authenticated access> **Note:** Ensure your SAS token has appropriate permissions (e.g., `r` for read access) and is configured with a suitable expiration for your use case.

### 2. Configure Spatie Media Library

[](#2-configure-spatie-media-library)

Update your Spatie Media Library configuration to use this package's URL generator. Publish the media library config if you haven't already:

```
php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="medialibrary-config"
```

Then, in `config/media-library.php`, set the custom URL generator:

```
'url_generator' => \BornMT\AzureBlobUrlGenerator\Services\UrlGeneratorService::class,
```

### 3. Configure Your Filesystem

[](#3-configure-your-filesystem)

Add the Azure disk to `config/filesystems.php`:

```
'disks' => [
    'azure' => [
        'driver' => 'azure-storage-blob',
        'sasToken' => env('AZURE_STORAGE_SAS_TOKEN'),
        'container' => env('AZURE_STORAGE_CONTAINER'),
        'endpoint' => env('AZURE_STORAGE_ENDPOINT'),
        'connection_string' => sprintf(
            'BlobEndpoint=%s;SharedAccessSignature=%s',
            env('AZURE_STORAGE_ENDPOINT'),
            env('AZURE_STORAGE_SAS_TOKEN')
        ),
    ],
],
```

Set your default media disk in `config/media-library.php` or via the `MEDIA_DISK` environment variable:

```
MEDIA_DISK=azure
```

Usage
-----

[](#usage)

Once configured, media URLs are generated automatically when you call `getUrl()` or `getTemporaryUrl()` on your media items.

### Basic Usage with Spatie Media Library

[](#basic-usage-with-spatie-media-library)

```
// Add media to a model
$yourModel->addMedia($pathToFile)
    ->toMediaCollection('documents', 'azure');

// Get the Azure Blob SAS URL
$media = $yourModel->getFirstMedia('documents');
$url = $media->getUrl();  // Returns full URL with SAS token

// Get a temporary URL (uses same SAS token - ensure your SAS has appropriate expiration)
$temporaryUrl = $media->getTemporaryUrl(now()->addHours(1));
```

Generated URL Format
--------------------

[](#generated-url-format)

URLs are generated in the following format:

```
{endpoint}/{container}/{path-to-file}?{sas_token}

```

Example:

```
https://mystorageaccount.blob.core.windows.net/my-container/media/1/image.jpg?sv=2021-06-08&ss=b&srt=sco&sp=rl&se=...

```

License
-------

[](#license)

The MIT License (MIT). Please see the [License File](LICENSE) for more information.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance82

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

96d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ed7d63f287f3876715c56f44853257d0d6fa6738a889f62884a1e3515c87aacd?d=identicon)[jeddsaliba-webeelabs](/maintainers/jeddsaliba-webeelabs)

![](https://www.gravatar.com/avatar/26da80e3517c5bc5e8517e105f42441b5b51c0395f6d708c2ead39d6ecdd4b08?d=identicon)[bornmt-dev](/maintainers/bornmt-dev)

---

Top Contributors

[![jeddsaliba-webeelabs](https://avatars.githubusercontent.com/u/234561695?v=4)](https://github.com/jeddsaliba-webeelabs "jeddsaliba-webeelabs (4 commits)")

---

Tags

urlazureblobSAS

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bornmt-azure-blob-url-generator/health.svg)

```
[![Health](https://phpackages.com/badges/bornmt-azure-blob-url-generator/health.svg)](https://phpackages.com/packages/bornmt-azure-blob-url-generator)
```

###  Alternatives

[microsoft/azure-storage-blob

This project provides a set of PHP client libraries that make it easy to access Microsoft Azure Storage Blob APIs.

5516.0M60](/packages/microsoft-azure-storage-blob)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[microsoft/azure-storage-common

This project provides a set of common code shared by Azure Storage Blob, Table, Queue and File PHP client libraries.

4316.8M6](/packages/microsoft-azure-storage-common)[azure-oss/storage

Azure Blob Storage PHP SDK

37985.0k5](/packages/azure-oss-storage)[microsoft/azure-storage-file

This project provides a set of PHP client libraries that make it easy to access Microsoft Azure Storage File APIs.

152.4M9](/packages/microsoft-azure-storage-file)[steffjenl/laravel-azure-blob-storage

Microsoft Azure Blob Storage integration for Laravel's Storage API

11152.8k](/packages/steffjenl-laravel-azure-blob-storage)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
