I just implemented this in a project the other day; just a note that some of the S3 compatible API's are V2, not V3 so you need flysystem/flysystem-aws-s3-v2.
You just create a service provider for the filesystem and have it build up the S3Client object with the parameters required. Here's what I built for connecting to DreamHost's system:
<?php
namespace App\Providers;
use Aws\S3\S3Client;
use League\Flysystem\AwsS3v2\AwsS3Adapter;
use League\Flysystem\Filesystem;
use Storage;
use Illuminate\Support\ServiceProvider;
class DreamStorageServiceProvider extends ServiceProvider
{
const DREAM_BASE_URL = 'https://objects-us-west-1.dream.io';
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
Storage::extend('dream', function ($app, $config) {
$config['base_url'] = isset($config['base_url']) ? $config['base_url'] : self::DREAM_BASE_URL;
$client = S3Client::factory($config);
return new Filesystem(new AwsS3Adapter($client, $config['bucket']));
});
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
//
}
}