PHPackages                             sausin/laravel-ovh - 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. sausin/laravel-ovh

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

sausin/laravel-ovh
==================

OVH Object Storage driver for laravel

v7.3.0(1y ago)40153.5k↑13%14[1 PRs](https://github.com/sausin/laravel-ovh/pulls)MITPHPPHP ^8.1CI failing

Since Mar 16Pushed 1y ago3 watchersCompare

[ Source](https://github.com/sausin/laravel-ovh)[ Packagist](https://packagist.org/packages/sausin/laravel-ovh)[ RSS](/packages/sausin-laravel-ovh/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (51)Used By (0)

Laravel OVH Object Storage driver
=================================

[](#laravel-ovh-object-storage-driver)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4c1031fb76c43aff9b8866fdec94bb6ed4d6f7b8241c9a30bcc8beb14d33deee/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73617573696e2f6c61726176656c2d6f76682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sausin/laravel-ovh)[![Continuous Integration](https://github.com/sausin/laravel-ovh/workflows/CI%20laravel-ovh/badge.svg?branch=master)](https://github.com/sausin/laravel-ovh/actions?query=workflow%3A%22CI+laravel-ovh%22)[![Quality Score](https://camo.githubusercontent.com/d36b7166a7526538e4f78c9aaa5670bf863078445fd8634d8e3d7693bc9a262c/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f73617573696e2f6c61726176656c2d6f76682e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/sausin/laravel-ovh)[![Total Downloads](https://camo.githubusercontent.com/8f88359f113c51192826a2b54612d28e1c6948ceb07d1c0959c8ac985170fb42/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73617573696e2f6c61726176656c2d6f76682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sausin/laravel-ovh)[![License: MIT](https://camo.githubusercontent.com/1b01ef0024ba0866c115986b895301f657c1b21fc29f05c4844b7f2e8d89204d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e7376673f7374796c653d666c61742d737175617265)](https://opensource.org/licenses/MIT)

Laravel `Storage` facade provides support for many different filesystems.

This is a wrapper to provide support in Laravel for [OVH Object Storage](https://www.ovh.ie/public-cloud/storage/object-storage/).

Installation
============

[](#installation)

Install via composer:

```
composer require sausin/laravel-ovh

```

Please see below for the details on various branches. You can choose the version of the package which is suitable for your development. Also, take note of the upgrade.

Package versionPHP compatibilityLaravel versionsSpecial features of OVHStatus`1.2.x``^7.0 - ^7.1``>=5.4`, `=7.1``>=5.4`, `=7.1``>=5.4`, `=7.2``>=5.4`Above + Set private key on containerDeprecated`5.x``>=7.4``>=5.8`Above + Config-based Expiring Objects + Form Post Signature + PrefixMaintained`6.x``>=7.4``>=7.x`PHP 8 supportActive`7.x``>=8.0``>=9.x`Laravel 9+ supportActiveIf you are using Laravel versions older than 5.5, add the service provider to the `providers` array in `config/app.php`:

```
Sausin\LaravelOvh\OVHServiceProvider::class
```

Define the ovh driver in the `config/filesystems.php`as below

```
'ovh' => [
    'driver' => 'ovh',
    'authUrl' => env('OS_AUTH_URL', 'https://auth.cloud.ovh.net/v3/'),
    'projectId' => env('OS_PROJECT_ID'),
    'region' => env('OS_REGION_NAME'),
    'userDomain' => env('OS_USER_DOMAIN_NAME', 'Default'),
    'username' => env('OS_USERNAME'),
    'password' => env('OS_PASSWORD'),
    'containerName' => env('OS_CONTAINER_NAME'),

    // Since v1.2
    // Optional variable and only if you are using temporary signed urls.
    // You can also set a new key using the command 'php artisan ovh:set-temp-url-key'.
    'tempUrlKey' => env('OS_TEMP_URL_KEY'),

    // Since v2.1
    // Optional variable and only if you have setup a custom endpoint.
    'endpoint' => env('OS_CUSTOM_ENDPOINT'),

    // Optional variables for handling large objects.
    // Defaults below are 300MB threshold & 100MB segments.
    'swiftLargeObjectThreshold' => env('OS_LARGE_OBJECT_THRESHOLD', 300 * 1024 * 1024),
    'swiftSegmentSize' => env('OS_SEGMENT_SIZE', 100 * 1024 * 1024),
    'swiftSegmentContainer' => env('OS_SEGMENT_CONTAINER', null),

    // Optional variable and only if you would like to DELETE all uploaded object by DEFAULT.
    // This allows you to set an 'expiration' time for every new uploaded object to
    // your container. This will not affect objects already in your container.
    //
    // If you're not willing to DELETE uploaded objects by DEFAULT, leave it empty.
    // Really, if you don't know what you're doing, you should leave this empty as well.
    'deleteAfter' => env('OS_DEFAULT_DELETE_AFTER', null),

    // Optional variable to cache your storage objects in memory
    // You must require league/flysystem-cached-adapter to enable caching
    // This option is not available on laravel-ovh >= 7.0
    'cache' => true, // Defaults to false

    // Optional variable to set a prefix on all paths
    'prefix' => null,
],
```

Define the correct env variables above in your .env file (to correspond to the values above), and you should now have a working OVH Object Storage setup 😄.

The environment variable `OS_AUTH_URL` is normally not going to be any different for OVH users and hence doesn't need to be specified. To get the values for remaining variables (like `OS_USERNAME`, `OS_REGION_NAME`, `OS_CONTAINER_NAME`, etc...), you can download the configuration file with details from OVH's Horizon or Control Panel:

- **OVH Control Panel**: `Public cloud -> Project Management -> Users & Roles -> Download Openstack's RC file`
- **OVH Horizon**: `Project -> API Access -> Download OpenStack RC File -> Identity API v3`

Be sure to clear your app's config cache after finishing this library's configuration:

```
php artisan config:cache
```

**NOTE**: Downloading your RC config file from **OVH Control Panel** will provide **Identity v2** variable names. However, for this package, the following variables are equivalent:

`laravel-ovh` variable nameOVH's RC variable name`OS_PROJECT_ID``OS_TENANT_ID``OS_PROJECT_NAME``OS_TENANT_NAME`You can safely place the values from the Identity v2 variables and place them in the corresponding variable for this package.

Upgrade Notes
-------------

[](#upgrade-notes)

### From 3.x to 4.x

[](#from-3x-to-4x)

Starting with `4.x` branch, the variables to be defined in the `.env` file have been renamed to reflect the names used by OpenStack in their configuration file. This is to remove any discrepancy in understanding which variable should go where. This also means that the package might fail to work unless the variable names in the `.env` file are updated.

### From 4.x to 5.x

[](#from-4x-to-5x)

Starting with `5.x` branch, the variables to be defined in the `config/filesystems.php`file have been renamed to better correspond with the names used by OpenStack in their configuration file. This is intended to give the developer a better understanding of the contents of each configuration key. If you're coming from `3.x`, updating the variable names in the `.env` might be essential to prevent failure.

### From 5.x/6.x to 7.x

[](#from-5x6x-to-7x)

Starting with `7.x` branch, only Laravel 9 and PHP 8 are supported. The `cache` option should be removed from your config if you previously used it since Flysystem no longer supports "cached adapters".

Usage
=====

[](#usage)

Refer to the extensive [Laravel Storage Documentation](https://laravel.com/docs/filesystem) for usage guidelines.

**NOTE:** This package includes support for the following additional methods:

```
Storage::url()
Storage::temporaryUrl()
```

The `temporaryUrl()` method is relevant for private containers where files are not publicly accessible under normal conditions. This generates a temporary signed url. For more details, please refer to [OVH's Temporary URL Documentation](https://docs.ovh.com/gb/en/public-cloud/share_an_object_via_a_temporary_url/).

Remember that this functionality requires the container to have a proper key stored. The key in the header should match the `tempUrlKey` specified in `config/filesystems.php`. For more details on how to set up the header on your OVH container, please refer to [Generate the temporary address (*tempurl*)](https://docs.ovh.com/gb/en/public-cloud/share_an_object_via_a_temporary_url/#generate-the-temporary-address-tempurl).

Alternatively, since version 4.x you can use the following commands:

```
# Automatically generate a key
php artisan ovh:set-temp-url-key

# Generate a key for a specific disk
php artisan ovh:set-temp-url-key --disk="other-ovh-disk"

# Set a specific key
php artisan ovh:set-temp-url-key --key=your-private-key
```

The package will then set the relevant key on your container and present it to you. If a key has already been set up previously, the package will warn you before overriding the existing key. If you'd like to force a new key anyway, you may use the `--force` flag with the command.

Once you got your key configured in your container, you must add it to your `.env` file:

```
OS_TEMP_URL_KEY='your-private-key'
```

Configuring a Custom Domain Name (Custom Endpoint)
--------------------------------------------------

[](#configuring-a-custom-domain-name-custom-endpoint)

OVH's Object Storage allows you to point a Custom Domain Name or Endpoint to an individual container. For this, you must setup some records with your DNS provider, which will authorize the forwarded requests coming from your Endpoint to OVH's servers.

In order to use a Custom Domain Name, you must specify it in your `.env` file:

```
OS_CUSTOM_ENDPOINT="http://my-endpoint.example.com"
```

For more information, please refer to [OVH's Custom Domain Documentation](https://docs.ovh.com/gb/en/storage/pcs/link-domain/).

Uploading Automatically Expiring Objects
----------------------------------------

[](#uploading-automatically-expiring-objects)

This library allows you to add expiration time to uploaded objects. There are 2 ways to do it:

1. Specifying expiration time programmatically:

    - You can either specify the number of seconds after which the uploaded object should be deleted: ```
        // Automatically expire after 1 hour of being uploaded.
        Storage::disk('ovh')->put('path/to/file.jpg', $contents, ['deleteAfter' => 60*60]);
        ```
    - Or, you can also specify a timestamp after which the uploaded object should be deleted: ```
        // Automatically delete at the beginning of next month.
        Storage::disk('ovh')->put('path/to/file.jpg', $contents, ['deleteAt' => now()->addMonth()->startOfMonth()])
        ```
2. Specifying default expiration time via `.env` file. This will set an expiration time (in seconds) to every newly uploaded object by default:

    ```
    # Delete every object after 3 days of being uploaded
    OS_DELETE_AFTER=259200
    ```

For more information about these variables, please refer to [OVH's Automatic Object Deletion Documentation](https://docs.ovh.com/gb/en/storage/configure_automatic_object_deletion/)

Large Object Support
--------------------

[](#large-object-support)

This library can help you optimize the upload speeds of large objects (such as videos or disk images) automatically by detecting file size thresholds and splitting the file into lighter segments. This will improve upload speeds by writing multiple segments into multiple Object Storage nodes simultaneously.

By default, the size threshold to detect a Large Object is set to 300MB, and the segment size to split the file is set to 100MB. If you would like to change these values, you must specify the following variables in your `.env` file (in Bytes):

```
# Set size threshold to 1GB
OS_LARGE_OBJECT_THRESHOLD=1073741824
# Set segment size to 200MB
OS_SEGMENT_SIZE=209715200
```

If you would like to use a separate container for storing your Large Object Segments, you can do so by specifing the following variable in your `.env` file:

```
OS_SEGMENT_CONTAINER="large-object-container-name"
```

Using a separate container for storing the segments of your Large Objects can be beneficial in some cases, to learn more about this, please refer to [OpenStack's Last Note on Using Swift for Large Objects](https://docs.openstack.org/swift/stein/overview_large_objects.html#using-swift)

To learn more about segmented uploads for large objects, please refer to:

- [OVH's Optimizing Large Object Uploads Documentation](https://docs.ovh.com/gb/en/storage/optimised_method_for_uploading_files_to_object_storage/)
- [OpenStack's Large Object Support Documentation](https://docs.openstack.org/swift/latest/overview_large_objects.html)

Form Post Middleware
--------------------

[](#form-post-middleware)

While this feature in not documented by the OVH team, it's explained in the [OpenStack's Documentation](https://docs.openstack.org/swift/latest/api/form_post_middleware.html).

This feature allows for uploading of files *directly* to the OVH servers rather than going through the application servers (thus improving the efficiency in the upload cycle).

You must generate a valid FormPost signature, for which you can use the following function:

```
Storage::disk('ovh')->getAdapter()->getFormPostSignature($path, $expiresAt, $redirect, $maxFileCount, $maxFileSize);
```

Where:

- `$path` is the directory path in which you would like to store the files.
- `$expiresAt` is a `DateTimeInterface` object that specifies a date in which the FormPost signature will expire.
- `$redirect` is the URL to which the user will be redirected once all files finish uploading. Defaults to `null` to prevent redirects.
- `$maxFileCount` is the max quantity of files that the user will be able to upload using the signature. Defaults to `1` file.
- `$maxFileSize` is the size limit that each uploaded file can have. Defaults to `25 MB` (`25*1024*1024`).

After obtaining the signature, you need to pass the signature data to your HTML form:

```

```

> **NOTE**: The upload method in the form *must* be type of `POST`.

> **NOTE**: As this will be a cross origin request, appropriate headers are needed on the container. See the use of command `php artisan ovh:set-cors-headers` further.

The `$url` variable refers to the path URL to your container, you can get it by passing the path to the adapter `getUrl`:

```
$url = Storage::disk('ovh')->getAdapter()->getUrl($path);
```

> **NOTE**: If you've setup a custom domain for your Object Storage container, you can use that domain (along with the corresponding path) to upload your files without exposing your OVH's URL scheme.

### Examples

[](#examples)

```
// Generate a signature that allows an upload to the 'images' directory for the next 10 minutes.
Storage::disk('ovh')->getAdapter()->getFormPostSignature('images', now()->addMinutes(10));

// Generate a signature that redirects to a url after successful file upload to the root of the container.
Storage::disk('ovh')->getAdapter()->getFormPostSignature('', now()->addMinutes(5), route('file-uploaded'));

// Generate a signature that allows upload of 3 files until next day.
Storage::disk('ovh')->getAdapter()->getFormPostSignature('', now()->addDay(), null, 3);

// Generate a signature that allows to upload 1 file of 1GB until the next hour.
Storage::disk('ovh')->getAdapter()->getFormPostSignature('', now()->addHour(), null, 1, 1 * 1024 * 1024 * 1024);
```

Setting up Access Control headers on the container
--------------------------------------------------

[](#setting-up-access-control-headers-on-the-container)

For the setup above to work correctly, the container must have the correct headers set on it. This package provides a convenient way to set them up using the below command

```
php artisan ovh:set-cors-headers
```

By default this will allow all origins to be able to upload on the container. However, if you would like to allow only specific origin(s) you may use the `--origins` flag.

If these headers were already set previously, the command will seek confirmation before overriding the existing headers.

Prefix &amp; Multi-tenancy
--------------------------

[](#prefix--multi-tenancy)

As noted above, `prefix` parameter was introduced in release 5.3.0. This means that any path specified when using the package will be prefixed with the given string. Nothing is added by default (or if the parameter has not been set at all).

For example, when `prefix` has been set as `foo` in the config, the following command:

```
Storage::disk('ovh')->url('/');
```

will generate a url as if it was requested with a path of `/foo` (i.e. the specified prefix has been used).

This is particularly powerful in a multi-tenant setup. The same container can be used for all tenants and yet each tenant can have its own folder, almost automatically. The middleware where the tenant is being set can be updated, and using the below command:

```
Config::set('filesystems.disks.ovh.prefix', 'someprefixvalue')
```

a separate custom prefix will be set for each tenant!

Both examples above assume the disk has been named as `ovh` in the config. Replace with the correct name for your case.

Credits
=======

[](#credits)

- ThePHPLeague for the awesome [Flysystem](https://github.com/thephpleague/flysystem)!
- [Chris Harvey](https://github.com/chrisnharvey) for the [Flysystem OpenStack SwiftAdapter](https://github.com/nimbusoftltd/flysystem-openstack-swift).
- Rackspace for maintaining the [PHP OpenStack Repo](https://github.com/php-opencloud/openstack).

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance46

Moderate activity, may be stable

Popularity46

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 86.2% 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 ~59 days

Recently: every ~268 days

Total

50

Last Release

429d ago

Major Versions

2.0.x-dev → v3.2.02020-03-05

3.0.x-dev → v4.0.02020-04-07

v4.0.3 → v5.0.02020-05-06

4.0.x-dev → v6.0.02021-04-05

v6.0.1 → v7.0.02022-04-08

PHP version history (6 changes)1.2.x-devPHP 7.0.x|7.1.x

v4.0.3PHP ^7.2

v5.0.0PHP ^7.4

v6.0.0PHP ^7.4|^8.0

v7.0.0PHP ^8.0

v7.1.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/1efa495645876ee7b1157fb11de36597784034a721f787738b655ac574bf88ef?d=identicon)[sausin](/maintainers/sausin)

---

Top Contributors

[![sausin](https://avatars.githubusercontent.com/u/11542923?v=4)](https://github.com/sausin "sausin (163 commits)")[![iksaku](https://avatars.githubusercontent.com/u/4632429?v=4)](https://github.com/iksaku "iksaku (16 commits)")[![wfeller](https://avatars.githubusercontent.com/u/21337627?v=4)](https://github.com/wfeller "wfeller (5 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (3 commits)")[![aliukevicius](https://avatars.githubusercontent.com/u/1206295?v=4)](https://github.com/aliukevicius "aliukevicius (1 commits)")[![jbeales](https://avatars.githubusercontent.com/u/104935?v=4)](https://github.com/jbeales "jbeales (1 commits)")

---

Tags

auto-deletionhacktoberfestlaravellaravel-ovhlaravel-packageobject-storageopenstackovhphpstoragetemporary-filesfilesystemFlysystemlaravelfilesstoragefilesystemsdriverOpenstackovhswiftopencloud

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/sausin-laravel-ovh/health.svg)

```
[![Health](https://phpackages.com/badges/sausin-laravel-ovh/health.svg)](https://phpackages.com/packages/sausin-laravel-ovh)
```

###  Alternatives

[nimbusoft/flysystem-openstack-swift

Flysystem adapter for OpenStack Swift

44774.4k6](/packages/nimbusoft-flysystem-openstack-swift)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M790](/packages/league-flysystem-aws-s3-v3)[zing/laravel-flysystem-obs

Flysystem Adapter for OBS

1211.2k](/packages/zing-laravel-flysystem-obs)

PHPackages © 2026

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