PHPackages                             tomshaw/laravel-dropbox - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. tomshaw/laravel-dropbox

ActiveLibrary[API Development](/categories/api)

tomshaw/laravel-dropbox
=======================

A Laravel Dropbox API client library.

v1.6.0(1mo ago)419MITPHPPHP ^8.5CI passing

Since Apr 14Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/tomshaw/laravel-dropbox)[ Packagist](https://packagist.org/packages/tomshaw/laravel-dropbox)[ Docs](https://github.com/tomshaw/laravel-dropbox)[ RSS](/packages/tomshaw-laravel-dropbox/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (9)Dependencies (30)Versions (27)Used By (0)

Laravel Dropbox 📂
=================

[](#laravel-dropbox-)

A Laravel Dropbox API 2.0 client library.

[![GitHub Workflow Status](https://camo.githubusercontent.com/1c9faad1288e20454a43f9fd715ca3b9161334896a2119ca150b0f362b1f77a2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f746f6d736861772f6c61726176656c2d64726f70626f782f72756e2d74657374732e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265266c6162656c3d7465737473)](https://camo.githubusercontent.com/1c9faad1288e20454a43f9fd715ca3b9161334896a2119ca150b0f362b1f77a2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f746f6d736861772f6c61726176656c2d64726f70626f782f72756e2d74657374732e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265266c6162656c3d7465737473)[![issues](https://camo.githubusercontent.com/5316d9b19b34f31d1b74c7354d00b27f571cb22345a9069c0779cfb3d59c91ac/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f746f6d736861772f6c61726176656c2d64726f70626f783f7374796c653d666c6174266c6f676f3d6170707665796f72)](https://camo.githubusercontent.com/5316d9b19b34f31d1b74c7354d00b27f571cb22345a9069c0779cfb3d59c91ac/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f746f6d736861772f6c61726176656c2d64726f70626f783f7374796c653d666c6174266c6f676f3d6170707665796f72)[![forks](https://camo.githubusercontent.com/428e7a7d978b4f88518216acf1f2142fd9127a1e8cb1f05a7453412e511afda5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f746f6d736861772f6c61726176656c2d64726f70626f783f7374796c653d666c6174266c6f676f3d6170707665796f72)](https://camo.githubusercontent.com/428e7a7d978b4f88518216acf1f2142fd9127a1e8cb1f05a7453412e511afda5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f746f6d736861772f6c61726176656c2d64726f70626f783f7374796c653d666c6174266c6f676f3d6170707665796f72)[![stars](https://camo.githubusercontent.com/376d6bd5a9654caa0670b2f13aacc5a036ddb17013dad1cf49310988ee0b04f8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f746f6d736861772f6c61726176656c2d64726f70626f783f7374796c653d666c6174266c6f676f3d6170707665796f72)](https://camo.githubusercontent.com/376d6bd5a9654caa0670b2f13aacc5a036ddb17013dad1cf49310988ee0b04f8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f746f6d736861772f6c61726176656c2d64726f70626f783f7374796c653d666c6174266c6f676f3d6170707665796f72)[![GitHub license](https://camo.githubusercontent.com/3d782cff25741c02866443e6ff8451ab221fd524c43d54b730fc2a9c5ad597e5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f746f6d736861772f6c61726176656c2d64726f70626f78)](https://github.com/tomshaw/laravel-dropbox/blob/master/LICENSE)

Requirements
------------

[](#requirements)

- PHP 8.5
- Laravel 13.0

Features
--------

[](#features)

- **Secure OAuth 2.0 Flow**: Authorization with CSRF `state` verification and PKCE (S256) code challenges out of the box.
- **Automatic Token Refresh**: Expiring tokens are refreshed transparently before every authenticated request — in controllers, queued jobs, and Artisan commands alike.
- **Customizable Token Storage**: User definable token storage adapters to suit your apps needs. Database-stored tokens are encrypted at rest.
- **Static Token Mode**: Set `DROPBOX_ACCESS_TOKEN` to skip the OAuth flow entirely for single-account, server-side integrations.
- **Large File Support**: Uploads above Dropbox's 150 MB single-request limit automatically switch to chunked upload sessions; downloads can stream straight to disk.
- **Resilient HTTP Layer**: Built on Laravel's HTTP client with configurable timeouts and automatic retries that honor Dropbox `Retry-After` rate-limit headers.
- **Typed Exceptions**: `DropboxException`, `AuthenticationException`, and `RateLimitException` expose the status code and parsed `error_summary` from Dropbox.
- **Laravel Facades Integration**: Built using Laravel Facades offering a familiar and simple interface that promotes readability, flexibility, testing and ease of use.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require tomshaw/laravel-dropbox
```

Next publish the configuration file:

```
php artisan vendor:publish --provider="TomShaw\Dropbox\Providers\DropboxServiceProvider" --tag=config

```

Run the migration if you wish to use database storage adapter:

```
php artisan migrate

```

Configuration
-------------

[](#configuration)

Here's a breakdown of each configuration option:

> The following variables should be set in your `.env` file

- `DROPBOX_CLIENT_ID`: The client ID for your Dropbox application.
- `DROPBOX_CLIENT_SECRET`: The client secret for your Dropbox application.
- `DROPBOX_REDIRECT_URI`: The URI to redirect to after Dropbox authentication.
- `DROPBOX_ACCESS_TOKEN`: A static access token used for all API requests. When set, the OAuth flow and token storage are bypassed entirely.
- `DROPBOX_ACCESS_TYPE`: This is the access type for the Dropbox application.
- `DROPBOX_ACCESS_SCOPES`: If omitted will request all scopes selected on the Permissions tab.
- `DROPBOX_TIMEOUT`: Request timeout in seconds (default `30`).
- `DROPBOX_RETRIES`: Number of attempts for rate-limited requests or failed connections (default `3`).

Token storage is configured via the `storage` key in the published `config/dropbox.php`. The default is `DatabaseTokenStorage` (encrypted, requires the migration); `SessionTokenStorage` is included for session-scoped tokens, or provide your own implementation of `TomShaw\Dropbox\Storage\StorageAdapterInterface`.

> Developers should review the [Dropbox Developer Platform](https://www.dropbox.com/developers) and [SDK Documentation](https://www.dropbox.com/developers/documentation) for further information.

Basic Usage
-----------

[](#basic-usage)

> Below is a cursory explanation of this repository's usage. Please refer to the appropriate Facade Resource for additional methods and usage.

> Verify your apps credentials utilizing the `check` accessor `app` method.

```
namespace App\Http\Controllers;

use TomShaw\Dropbox\Dropbox;
use TomShaw\Dropbox\DropboxClient;

class DropboxController extends Controller
{
    public function check()
    {
        Dropbox::check()->app();
    }
}
```

> Authorizing the application and persisting the token.

```
namespace App\Http\Controllers;

use TomShaw\Dropbox\Dropbox;

class DropboxController extends Controller
{
    public function connect()
    {
        if (request()->has('code')) {

            Dropbox::connect(request('code'), request('state'));

            return redirect()->route('dashboard');
        }

        return redirect()->away(Dropbox::getAuthUrl());
    }
}
```

> Revoking access using the `revoke` accessor.

```
namespace App\Http\Controllers;

use TomShaw\Dropbox\Dropbox;

class DropboxController extends Controller
{
    public function revoke()
    {
        Dropbox::revoke();

        return redirect()->route('dashboard');
    }
}
```

> Requesting account information using the `users` accessor.

```
namespace App\Http\Controllers;

use TomShaw\Dropbox\Dropbox;

class DropboxController extends Controller
{
    public function account()
    {
        Dropbox::users()->getCurrentAccount();
    }
}
```

> Creating folders using the `files` accessor.

```
namespace App\Http\Controllers;

use TomShaw\Dropbox\Dropbox;

class DropboxController extends Controller
{
    public function createfolder(string $path)
    {
        Dropbox::files()->createFolder($path, true);
    }
}
```

> Downloading files using the `files` accessor.

```
namespace App\Http\Controllers;

use TomShaw\Dropbox\Dropbox;

class DropboxController extends Controller
{
    public function download($id)
    {
        $item = Dropbox::files()->getMetadata($id);

        if ($item) {
            $fileContents = Dropbox::files()->download($item['path_lower']);

            return response($fileContents, 200, [
                'Content-Type' => 'application/octet-stream',
                'Content-Disposition' => 'attachment; filename="' . $item['name'] . '"',
            ]);
        }

        return abort(404);
    }
}
```

> Large downloads can stream directly to a local path without buffering in memory. The file metadata is returned from the `Dropbox-API-Result` header.

```
$metadata = Dropbox::files()->downloadTo('/videos/demo.mp4', storage_path('app/demo.mp4'));
```

> Uploading files using the `files` accessor. Files above Dropbox's 150 MB single-request limit are automatically sent through a chunked upload session; use `uploadSession()` to force chunked uploads at any size.

```
namespace App\Http\Controllers;

use TomShaw\Dropbox\Dropbox;
use TomShaw\Dropbox\Enums\WriteMode;

class DropboxController extends Controller
{
    public function upload(string $destinationPath, string $sourceFilePath)
    {
        Dropbox::files()->upload($destinationPath, $sourceFilePath, mode: WriteMode::Add, autorename: false, mute: false, strictConflict: false);
    }
}
```

> Handling Dropbox API errors with typed exceptions.

```
use TomShaw\Dropbox\Exceptions\{AuthenticationException, DropboxException, RateLimitException};

try {
    Dropbox::files()->getMetadata('/missing.txt');
} catch (RateLimitException $e) {
    // $e->retryAfter (seconds), after built-in retries were exhausted
} catch (AuthenticationException $e) {
    // Token invalid, revoked, or the OAuth flow has not completed
} catch (DropboxException $e) {
    // $e->status and $e->errorBody['error_summary']
}
```

> Sharing a link using the `sharing` accessor.

```
namespace App\Http\Controllers;

use TomShaw\Dropbox\Dropbox;
use TomShaw\Dropbox\DropboxClient;

class DropboxController extends Controller
{
    public function sharelink(string $path)
    {
        Dropbox::sharing()->createSharedLinkWithSettings($path, ['requested_visibility' => 'public']);
    }
}
```

Middleware
----------

[](#middleware)

Add the included Dropbox `middleware` to any routes that require API access. Requests without a stored token are redirected to the Dropbox authorization page; requests expecting JSON receive a `401` response instead.

```
Route::group(['middleware' => ['web', 'auth', 'dropbox']], function () {
  /* Grouped routes */
});
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Changelog
---------

[](#changelog)

For changes made to the project, see the [Changelog](CHANGELOG.md).

License
-------

[](#license)

The MIT License (MIT). See [License File](LICENSE) for more information.

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance91

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~37 days

Total

23

Last Release

44d ago

Major Versions

v0.2.3 → v1.0.02024-04-18

v0.2.4 → v1.1.12025-02-02

PHP version history (5 changes)v0.1.0PHP ^8.1|^8.2

v1.1.1PHP ^8.1|^8.2|^8.3|^8.4

v1.1.2PHP ^8.2|^8.3|^8.4

v1.2.0PHP ^8.2|^8.3|^8.4|^8.5

v1.3.0PHP ^8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/14fd02efdbaf6247b61c9846697c86dabcbf430374aeff0d80e509d95d186658?d=identicon)[Tom Shaw](/maintainers/Tom%20Shaw)

---

Top Contributors

[![tomshaw](https://avatars.githubusercontent.com/u/32818?v=4)](https://github.com/tomshaw "tomshaw (73 commits)")

---

Tags

laraveldropbox

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/tomshaw-laravel-dropbox/health.svg)

```
[![Health](https://phpackages.com/badges/tomshaw-laravel-dropbox/health.svg)](https://phpackages.com/packages/tomshaw-laravel-dropbox)
```

###  Alternatives

[statamic/cms

The Statamic CMS Core Package

4.9k3.8M1.2k](/packages/statamic-cms)[unopim/unopim

UnoPim Laravel PIM

10.8k2.5k](/packages/unopim-unopim)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5226.7k](/packages/simplestats-io-laravel-client)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

353.6k](/packages/eslazarev-wildberries-sdk)[scriptdevelop/whatsapp-manager

Paquete para manejo de WhatsApp Business API en Laravel

793.9k](/packages/scriptdevelop-whatsapp-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
