PHPackages                             axinter/azureblobstorage - 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. axinter/azureblobstorage

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

axinter/azureblobstorage
========================

Azure Blob Storage integration for Symfony and Laravel

0.1.4(5mo ago)054MITPHPPHP ^8.1

Since Dec 3Pushed 5mo agoCompare

[ Source](https://github.com/axinter-devops/azureblobstorage)[ Packagist](https://packagist.org/packages/axinter/azureblobstorage)[ RSS](/packages/axinter-azureblobstorage/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Azure Blob Storage for PHP
==========================

[](#azure-blob-storage-for-php)

A modern PHP library for interacting with Azure Blob Storage, designed for seamless integration with Symfony and Laravel applications.

Features
--------

[](#features)

- 🚀 **Simple API** - Intuitive methods for common blob operations
- 📦 **Framework Agnostic** - Works with Symfony, Laravel, or any PHP project
- 🔄 **Version Control** - Built-in blob versioning support (custom implementation for Azurite)
- 📁 **Container Management** - Create, delete, and check container existence
- 📊 **Metadata Support** - Set and retrieve custom metadata on blobs
- 🌊 **Stream Support** - Upload and download large files using streams
- 🔐 **Secure Authentication** - Shared Key authentication using azure-oss/storage

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

[](#requirements)

- PHP 8.1 or higher
- Guzzle HTTP client 7.0+
- Azure Storage account or Azurite emulator

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

[](#installation)

Install via Composer:

```
composer require axinter/azureblobstorage
```

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

[](#configuration)

### Basic Setup

[](#basic-setup)

Create a configuration object using your Azure Storage connection string:

```
use AxInter\AzureBlobStorage\Config;
use AxInter\AzureBlobStorage\FileSystem;

$connectionString = 'DefaultEndpointsProtocol=https;AccountName=your-account;AccountKey=your-key;EndpointSuffix=core.windows.net';
$config = new Config($connectionString);
$fileSystem = new FileSystem($config, 'your-container-name');
```

### Azurite (Local Development)

[](#azurite-local-development)

```
$connectionString = 'DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1';
$config = new Config($connectionString);
$fileSystem = new FileSystem($config, 'test-container');
```

Usage
-----

[](#usage)

### Container Operations

[](#container-operations)

```
// Create a container
$fileSystem->createContainer();

// Check if container exists
if ($fileSystem->containerExists()) {
    echo "Container exists!";
}

// Delete a container
$fileSystem->deleteContainer();
```

### File Operations

[](#file-operations)

#### Upload Files

[](#upload-files)

```
// Write string content
$fileSystem->write('path/to/file.txt', 'Hello, Azure!');

// Upload from stream (efficient for large files)
$stream = fopen('/path/to/large-file.pdf', 'r');
$fileSystem->writeStream('documents/large-file.pdf', $stream);
fclose($stream);
```

#### Download Files

[](#download-files)

```
// Read file content as string
$content = $fileSystem->read('path/to/file.txt');

// Download as stream
$stream = $fileSystem->readStream('documents/large-file.pdf');
file_put_contents('/local/path/file.pdf', $stream);
```

#### File Management

[](#file-management)

```
// Check if file exists
if ($fileSystem->exists('path/to/file.txt')) {
    echo "File exists!";
}

// Get file information
$size = $fileSystem->getSize('path/to/file.txt');
$mimeType = $fileSystem->getMimeType('path/to/file.txt');
$url = $fileSystem->getUrl('path/to/file.txt');

// Copy file
$fileSystem->copy('source.txt', 'destination.txt');

// Move file
$fileSystem->move('old-path.txt', 'new-path.txt');

// Delete file
$fileSystem->delete('path/to/file.txt');
```

### List Files

[](#list-files)

```
// List all files in container
$files = $fileSystem->list();

// List files with prefix
$files = $fileSystem->list('documents/');

foreach ($files as $file) {
    echo "Name: {$file['name']}\n";
    echo "Size: {$file['size']} bytes\n";
    echo "Last Modified: {$file['last_modified']}\n";
    echo "Content Type: {$file['content_type']}\n";
}
```

### Metadata

[](#metadata)

```
// Set custom metadata
$fileSystem->setMetadata('path/to/file.txt', [
    'author' => 'John Doe',
    'department' => 'Engineering',
    'version' => '1.0'
]);

// Retrieve metadata
$metadata = $fileSystem->getMetadata('path/to/file.txt');
echo $metadata['author']; // John Doe
```

### Version Control

[](#version-control)

The library includes custom version control for blob storage (particularly useful with Azurite which doesn't support native versioning):

```
// Write operations automatically create versions
$fileSystem->write('document.txt', 'Version 1');
$fileSystem->write('document.txt', 'Version 2'); // Previous version saved automatically

// List all versions
$versions = $fileSystem->listVersions('document.txt');
foreach ($versions as $version) {
    echo "Version ID: {$version['version_id']}\n";
    echo "Is Current: {$version['is_current_version']}\n";
    echo "Modified: {$version['last_modified']}\n";
}

// Get specific version
$oldContent = $fileSystem->getVersion('document.txt', '1703001234');

// Restore previous version (creates a new current version)
$fileSystem->restoreVersion('document.txt', '1703001234');

// Delete a specific version
$fileSystem->deleteVersion('document.txt', '1703001234');
```

Exception Handling
------------------

[](#exception-handling)

The library provides specific exceptions for different error scenarios:

```
use AxInter\AzureBlobStorage\Exceptions\BlobNotFoundException;
use AxInter\AzureBlobStorage\Exceptions\InvalidStreamException;
use AxInter\AzureBlobStorage\Exceptions\VersionNotFoundException;
use AxInter\AzureBlobStorage\Exceptions\AzureBlobStorageException;

try {
    $content = $fileSystem->read('non-existent.txt');
} catch (BlobNotFoundException $e) {
    echo "File not found: " . $e->getMessage();
} catch (AzureBlobStorageException $e) {
    echo "Storage error: " . $e->getMessage();
}
```

API Reference
-------------

[](#api-reference)

### FileSystem Methods

[](#filesystem-methods)

MethodParametersReturnsDescription`write()``string $path, string $contents``bool`Write content to a blob`read()``string $path``?string`Read blob content`delete()``string $path``bool`Delete a blob`exists()``string $path``bool`Check if blob exists`copy()``string $source, string $dest``bool`Copy a blob`move()``string $source, string $dest``bool`Move a blob`list()``string $prefix = ''``array`List blobs with optional prefix`getSize()``string $path``?int`Get blob size in bytes`getMimeType()``string $path``?string`Get blob MIME type`getUrl()``string $path``string`Get blob URL`writeStream()``string $path, resource $stream``bool`Upload from stream`readStream()``string $path``resource|null`Download as stream`setMetadata()``string $path, array $metadata``bool`Set blob metadata`getMetadata()``string $path``?array`Get blob metadata`listVersions()``string $path``array`List all versions of a blob`getVersion()``string $path, string $versionId``?string`Get specific version content`restoreVersion()``string $path, string $versionId``bool`Restore a previous version`deleteVersion()``string $path, string $versionId``bool`Delete a specific versionTesting
-------

[](#testing)

Run the test suite:

```
composer install
vendor/bin/phpunit
```

License
-------

[](#license)

MIT License - see LICENSE file for details

Author
------

[](#author)

- **Joakim Stenberg** - [AxInter](https://axinter.com)

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

Support
-------

[](#support)

For issues and feature requests, please use the [GitHub issue tracker](https://github.com/axinter/azureblobstorage/issues)

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance73

Regular maintenance activity

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 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

Every ~15 days

Total

2

Last Release

151d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2e3ade274e66c308cfc4feaaf8c45b0e8d041fecaeaf62c371b44d66ea6e963e?d=identicon)[axinterjoakim](/maintainers/axinterjoakim)

---

Top Contributors

[![joakimaxinter](https://avatars.githubusercontent.com/u/236987630?v=4)](https://github.com/joakimaxinter "joakimaxinter (4 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/axinter-azureblobstorage/health.svg)

```
[![Health](https://phpackages.com/badges/axinter-azureblobstorage/health.svg)](https://phpackages.com/packages/axinter-azureblobstorage)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.2k511.3M2.2k](/packages/aws-aws-sdk-php)[google/cloud

Google Cloud Client Library

1.2k16.2M53](/packages/google-cloud)[stechstudio/laravel-zipstream

A fast and simple streaming zip file downloader for Laravel.

4633.7M3](/packages/stechstudio-laravel-zipstream)[fof/upload

The file upload extension for the Flarum forum with insane intelligence.

188171.7k15](/packages/fof-upload)[uploadcare/uploadcare-php

Uploadcare PHP integration handles uploads and further operations with files by wrapping Upload and REST APIs.

1022.5M6](/packages/uploadcare-uploadcare-php)[azure-oss/storage

Azure Blob Storage PHP SDK

37985.0k5](/packages/azure-oss-storage)

PHPackages © 2026

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