Using Linode/Akamai for your S3 storage in Laravel

5 May 2024

I've been working on an interesting SaaS project, where users can upload photos and lots of them. Therefore I needed a storage solution and since I am already using Linode (not affiliated), that's what I'll be using. In this post I'll detail how I set it up in my project and how you too can get Linode's object storage integrated into your Laravel application.

Setting up Linode Object Storage

First we need to set up a bucket on Linode. This is done by logging into or creating your Linode account. When logged in click on the Object Storage menu and from there click on Create bucket. Give your bucket a suited name and select a region. Remember these values as they will be used later.
Create bucket

Create a bucket.

With your bucket created click over to the Access Keys-tab and click Create Access Key. In the menu select your newly created bucket and give it the desired permissions. This will give you your access key and access secret, which you'll also need later.
Create access key

Create an access key.

The access key generated

The generated access key.

This concludes the setup at Linode and we can move on to the Laravel application.

Configuring your Laravel application

To use the Linode storage in your application we need to setup a fews things first. Since Linode Object Storage is S3 compatible, we can use the S3 driver in Laravel to manage files.

To use the S3 driver, we need to install the flysystem-package in Laravel. Use the following command to do so:
composer require league/flysystem-aws-s3-v3 ^3.0
Then we need to setup some environment variables in the .env-file of your Laravel application.
Fill in the information you got when setting up your bucket and access . Please note that the LINODE_ENDPOINT is comprised of the region and (it doesn't include the bucket name). Then go to your config/filesystems.php config file and add the following in the disks array.
'disks' => [

    'linode' => [
        'driver' => 's3',
        'key' => env('LINODE_KEY'),
        'secret' => env('LINODE_SECRET'),
        'endpoint' => env('LINODE_ENDPOINT'),
        'region' => env('LINODE_REGION'),
        'bucket' => env('LINODE_BUCKET'),
If you want to use the Linode storage as your default storage, you can now add the following to your .env-file.
At this point I like to verify that my connection is working. You can do this by adding the following piece of code in your Laravel application and running it.
\Illuminate\Support\Facades\Storage::put('test.txt', '123');
If your connection is working, this should place a simple test.txt file in the root of your storage.

If you are experiencing issues, you may want to add the 'throw' => true option in your config/filesystems.php. The option (if set to true) throws an exception when write operations fail and gives you a bit of info as to why.

Happy coding!

You might also enjoy

The Seven Restful Controller Actions in Laravel

The Seven Restful Controller Actions in Laravel

Published 2024-05-05 — Updated 2024-05-16



Web development

The seven RESTful actions and how you could implement them in Laravel

Read the post →
Useful Laravel packages

Useful Laravel packages

Published 2024-05-05



Web development

Learn what packages that can help you build even better websites in Laravel. We'll go trhough the must-haves and packages that are just nice to have.

Read the post →
Getting title tag and meta tags from a website using PHP

Getting title tag and meta tags from a website using PHP

Published 2024-05-14


Web development

Learn how to easily webscrape title and meta tags from a website using simple PHP commands.

Read the post →