DO Ideas 2

Add Laravel storage driver for digitalocean spaces

Hello Guys,

As you all know Laravel is the most popular framework in the PHP world and it has the biggest community. The only official driver storage that are available are Amazon S3 and Rackspace.

I think this is super good for laravel community to have official Digitalocean Spaces package(laravel driver).

I am pretty sure that laravel community all need this, who is already using DO droplets and now can manage their spaces storage right next to their space storage.

  • Mehran Hadidi
  • Sep 11 2018
  • Attach files
  • Anonymous commented
    September 11, 2018 15:57

    You can just use the existing driver as Spaces uses the S3 API

  • emkei commented
    September 11, 2018 15:57
  • Stefan commented
    September 11, 2018 15:57

    Just to expand upon Joe Lennon's comment and tutorial - I didn't even need to create a new driver.

    I simply used the existing S3 driver, but added more options to the filesystems.php config:

    's3' => [
    'driver' => env('S3_DRIVER', 's3'),
    'endpoint' => env('S3_ENDPOINT'),
    'version' => env('S3_VERSION', 'latest'),
    'key' => env('S3_KEY'),
    'secret' => env('S3_SECRET'),
    'region' => env('S3_REGION'),
    'bucket' => env('S3_BUCKET'),
    'root' => env('S3_ROOT'),
    ],

    This seemed to work fine in early tests.

  • Joe Lennon commented
    September 11, 2018 15:57

    Because Spaces has an S3-compatible API it's pretty straightforward to add your own driver. Basically you use the `Storage::extend` method, and call the AWS S3 adapter but provide the DigitalOcean Spaces endpoint rather than the Amazon one. I've written about how to do this in more detail at https://joelennon.com/using-digitalocean-spaces-in-laravel.