“I created an AI assistant for Laravel developers that handles all the boring work.”
Learn more
Smousss
Benjamin Crozat The art of crafting web applications

Laravel Dropbox Driver package: how to install and use it

Benjamin Crozat — Updated on

Table of contents

Laravel Dropbox Driver package: how to install and use it

Adding a new disk in the storage is easy. The only things I did was:

Requirements

Laravel Dropbox Driver requires:

Installation

To install Laravel Dropbox Driver, run the command below:

composer require benjamincrozat/laravel-dropbox-driver

Usage in your project

Add the following in app/filesystems.php:

'disks' => [
 
'dropbox' => [
'driver' => 'dropbox',
'token' => env('DROPBOX_TOKEN'),
],
 
],

Then, in your .env file:

DROPBOX_TOKEN=your_access_token

Get a token from Dropbox

Log in to your Dropbox account and create a new application to generate your access token.

https://www.dropbox.com/developers/apps/create

Apps creation on Dropbox.

License

Take this package and do whatever the f you want with it. That’s basically what the WTFPL license says.

What can you do with Laravel Dropbox Driver?

The Laravel Dropbox Driver package allows you to use storage anything you’d like on Dropbox from your Laravel applications. Here are some example use cases I could think about:

How to create a custom storage driver in Laravel?

To create a custom storage driver in Laravel, you will need to do the following:

Here’s an example of what a custom storage driver class looks like:

namespace App\Filesystem;
 
use Illuminate\Contracts\Filesystem\Filesystem;
 
class CustomStorage implements Filesystem
{
public function put($path, $contents, $visibility = null)
{
// Implement custom logic for storing a file...
}
 
public function get($path)
{
// Implement custom logic for retrieving a file...
}
 
public function delete($path)
{
// Implement custom logic for deleting a file...
}
 
// Implement other methods from the Filesystem contract...
}

You can then register your custom storage driver in the config/filesystems.php configuration file like this:

'disks' => [
'custom' => [
'driver' => App\Filesystem\CustomStorage::class,
'key' => 'your-api-key',
'secret' => 'your-api-secret',
],
],

And finally, you can use your custom storage driver in your Laravel code like this:

use Illuminate\Support\Facades\Storage;
 
// Use the "custom" disk...
Storage::disk('custom')->put('file.txt', 'Contents');
Recommended

Learning a framework can be overwhelming, but time and execution will make you a master. Here are some best practices to help you toward your goal.

Laravel Collections make arrays more powerful and convenient to work with. This article provides tons of quick tips to instantly make your codebase better.

Start leveraging the power of AI today. It enables developers to do incredible things, and many startups build products around it.

Laravel 10 has been released on February 14, 2023. Let's dive into every relevant new feature and change.

switch, case, and break. What are all these? When should you use it instead of if? What are its pros and cons?

Debugging requires dissecting everything. Here's a list of all the one-line of code built-in ways to print arrays in PHP (and even Laravel-specific helpers).

Nailing a Laravel job interview can be a daunting task, but with the right preparation and mindset, you can set yourself up for success.

There are multiple ways to check if an array is empty. Let me tell you about each of them and why and when you should use them.

I show you how to upgrade your Laravel 9 project to version 10 and help you decide whether the return on investment is worth it.

I show you how to upgrade your Laravel 8 project to version 9 and help you decide whether the return on investment is worth it.

Powered by