Download the PHP package sausin/laravel-ovh without Composer
On this page you can find all versions of the php package sausin/laravel-ovh. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-ovh
Laravel OVH Object Storage driver
Laravel Storage
facade provides support for many different filesystems.
This is a wrapper to provide support in Laravel for OVH Object Storage.
Installation
Install via composer:
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 version | PHP compatibility | Laravel versions | Special features of OVH | Status |
---|---|---|---|---|
1.2.x |
^7.0 - ^7.1 |
>=5.4 , <=5.8 |
Temporary Url Support | Deprecated |
2.x |
>=7.1 |
>=5.4 , <=6.x |
Above + Expiring Objects + Custom Domains | Deprecated |
3.x |
>=7.1 |
>=5.4 , <=7.x |
Above + Keystone v3 API | Deprecated |
4.x |
>=7.2 |
>=5.4 |
Above + Set private key on container | Deprecated |
5.x |
>=7.4 |
>=5.8 |
Above + Config-based Expiring Objects + Form Post Signature + Prefix | Maintained |
6.x |
>=7.4 |
>=7.x |
PHP 8 support | Active |
7.x |
>=8.0 |
>=9.x |
Laravel 9+ support | Active |
If you are using Laravel versions older than 5.5, add the service provider to the providers
array in config/app.php
:
Define the ovh driver in the config/filesystems.php
as below
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 :smile:.
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:
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 name |
OVH'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
From 3.x to 4.x
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
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
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
Refer to the extensive Laravel Storage Documentation for usage guidelines.
NOTE: This package includes support for the following additional methods:
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.
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).
Alternatively, since version 4.x you can use the following commands:
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:
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:
For more information, please refer to OVH's Custom Domain Documentation.
Uploading Automatically Expiring Objects
This library allows you to add expiration time to uploaded objects. There are 2 ways to do it:
-
Specifying expiration time programmatically:
-
You can either specify the number of seconds after which the uploaded object should be deleted:
- Or, you can also specify a timestamp after which the uploaded object should be deleted:
-
- Specifying default expiration time via
.env
file. This will set an expiration time (in seconds) to every newly uploaded object by default:
For more information about these variables, please refer to OVH's Automatic Object Deletion Documentation
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):
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:
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
To learn more about segmented uploads for large objects, please refer to:
Form Post Middleware
While this feature in not documented by the OVH team, it's explained in the OpenStack's Documentation.
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:
Where:
$path
is the directory path in which you would like to store the files.$expiresAt
is aDateTimeInterface
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 tonull
to prevent redirects.$maxFileCount
is the max quantity of files that the user will be able to upload using the signature. Defaults to1
file.$maxFileSize
is the size limit that each uploaded file can have. Defaults to25 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
:
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
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
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 & 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:
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:
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
- ThePHPLeague for the awesome Flysystem!
- Chris Harvey for the Flysystem OpenStack SwiftAdapter.
- Rackspace for maintaining the PHP OpenStack Repo.
All versions of laravel-ovh with dependencies
illuminate/console Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.0
nimbusoft/flysystem-openstack-swift Version ^1.5