kunalvarma05/dropbox-php-sdk
A PHP SDK for Dropbox API v2 with a clean object-oriented interface for OAuth, file uploads and downloads, sharing, metadata, and folder management. Includes Laravel service provider and facade integration for quick Dropbox access in PHP and Laravel apps.
v0.5.0 is a compatibility release, not a feature release: the only change is the composer.json constraints adding Laravel 11 support (PR #211). There are no API changes, no deprecations, and no new methods versus v0.4.2. If you are already on 0.4.x under Laravel ≤10, this is a routine bump; if you are migrating an app to Laravel 11, this is the first version of the SDK that will install cleanly alongside laravel/framework:^11.0.
Minimum path to a working call:
composer require kunalvarma05/dropbox-php-sdk:^0.5 — Laravel 11 pulls PHP 8.2+, so confirm your runtime before bumping.Kunnu\Dropbox\DropboxServiceProvider and the Dropbox facade alias automatically; there is nothing to add to config/app.php.php artisan vendor:publish --provider="Kunnu\Dropbox\DropboxServiceProvider". On a slim Laravel 11 skeleton there is no config/dropbox.php until you do this, and every config('dropbox.*') lookup will be null otherwise..env and .env.example: app key/secret plus an access token (and a refresh token — see Gotchas). Dropbox app console → your app → Permissions must include files.content.write / files.content.read for anything beyond metadata, and scoped apps need the scopes set before you generate the token.use Kunnu\Dropbox\Models\UploadArg; // argument/response models live in src/Models
$response = \Dropbox::files()->upload(
new UploadArg('/Reports/2024-06.pdf'),
fopen(storage_path('app/reports/2024-06.pdf'), 'rb')
);
Where to look first, in order: the GitHub README (only real documentation), src/Dropbox.php (the files(), users(), auth() entry points), src/Models (argument objects — the SDK does not take plain arrays everywhere, which is the most common first surprise), and src/Exceptions.
Put the facade behind your own interface. The SDK has no Laravel filesystem driver, so Storage::disk('dropbox') is not available. Wrap the handful of operations you actually use (upload, download, listFolder, delete, getTemporaryLink) in a small DropboxStorage class bound in a service provider. When you eventually need to swap to the official dropbox/dropbox-sdk-php — worth considering given the release cadence — it becomes a one-class change instead of a grep across the codebase.
Resolve instances per tenant instead of relying on the singleton. The container binding is configured once from config/dropbox.php. For per-user or per-team credentials, construct the client yourself from the app key/secret and that user's stored token, or forget the resolved instance (app()->forgetInstance('dropbox')) before re-resolving. Store tokens with encrypted casts — they are bearer credentials.
Persist rotated tokens. Dropbox moved to short-lived access tokens with refresh tokens years ago; most blog posts and StackOverflow answers still assume the old long-lived tokens and will lead you into a 401 loop. After any refresh, write the new token back to storage in the same request. The SDK exposes refresh helpers on the client — verify the exact method name against src/Dropbox.php for your pinned version rather than trusting a snippet.
Queue the transfers. Uploads and downloads are synchronous HTTP calls with real latency; a 40 MB PDF on a request thread will blow past typical timeouts and tie up a PHP-FPM worker. Use a job with $timeout set well above the default, and for large files use the SDK's chunked-upload path rather than one giant request.
Paginate listings deliberately. listFolder returns a cursor and a has_more flag; a naive call silently truncates at the page size. Loop with the continue call until has_more is false, and put a hard iteration cap in so a runaway loop can't hang a queue worker.
Prefer temporary links over proxying bytes. getTemporaryLink gives you a pre-signed URL you can hand straight to the browser or an <img> tag. Proxying downloads through a controller costs you bandwidth, memory, and a PHP worker for no benefit.
Webhooks need CSRF exclusion and raw-body access. Dropbox POSTs to your endpoint with an HMAC signature over the raw body. In Laravel 11 that means $middleware->validateCsrfTokens(except: ['webhooks/dropbox']) in bootstrap/app.php, and reading $request->getContent() before any middleware mangles it. Verify the signature with the app secret and reject mismatches with a 403 before touching the payload.
Testing. Never hit the live API in CI. Mock your own interface (cheap, stable), or bind a fake into the container for the Dropbox binding. There is no built-in fake, so mocking the SDK class directly means stubbing model return types — another reason to own the interface.
composer.json. If you were hoping for Laravel 11 features (or fixes), there are none. Pin ^0.5 and diff v0.4.2...v0.5.0 yourself — it takes ten seconds.UploadArg, CreateFolderArg and friends. Passing ['path' => ...] fails with a type error that reads like a bug in the package. Check src/Models first whenever a call "doesn't work".DropboxClientException (not \Exception), inspect the error summary/code, and back off with retry() or a queued release. Mask tokens before logging any exception message.config:cache in deployment is mandatory and also a trap. The SDK reads config at resolution time; if you use env() anywhere outside config/dropbox.php it will silently return null once config is cached. Publish the config and keep every env() call inside it.createFolder calls will fail on first run of a fresh environment.DropboxApp and Dropbox are ordinary constructible classes, exceptions extend the client exception, and there are no Laravel events fired — if you want telemetry, wrap the calls in your own decorator. That is also the cheapest place to add retry/backoff and request-id logging.php artisan about and composer why-not kunalvarma05/dropbox-php-sdk 0.5.0 when the upgrade won't resolve — it is almost always a transitive illuminate/support constraint from another package, not this one.How can I help you explore Laravel packages today?