Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Dropbox Php Sdk Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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:

  1. composer require kunalvarma05/dropbox-php-sdk:^0.5 — Laravel 11 pulls PHP 8.2+, so confirm your runtime before bumping.
  2. Package discovery registers Kunnu\Dropbox\DropboxServiceProvider and the Dropbox facade alias automatically; there is nothing to add to config/app.php.
  3. Publish the config: 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.
  4. Add credentials to .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.
  5. First use case to validate the install: push a generated report into a shared folder.
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.

Implementation Patterns

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.

Gotchas and Tips

  • Read the changelog before you celebrate. v0.5.0 changes exactly one line of 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.
  • Release cadence is the real risk. This is a community SDK whose release history has long gaps; the official Dropbox PHP SDK is the safer long-term bet for anything mission-critical. Keep the abstraction layer described above so the decision stays reversible.
  • Arguments are objects, not arrays. 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".
  • Rate limits are normal, not exceptional. Expect 429s on backfills and bulk syncs. Catch the SDK's 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.
  • Path handling. Dropbox paths are case-insensitive but case-preserving, and there is no distinction between a missing file and a missing parent folder when creating — create parents explicitly or your createFolder calls will fail on first run of a fresh environment.
  • Response objects are not arrays. Upload/download/list responses are model objects with getters. Cast or map them at the boundary of your service class so the rest of your app isn't coupled to SDK internals.
  • Extension points are plain PHP. 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.
  • Laravel 11 housekeeping. Run 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.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource