Download the PHP package kalprajsolutions/laravel-onedrive-filesystem without Composer
On this page you can find all versions of the php package kalprajsolutions/laravel-onedrive-filesystem. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kalprajsolutions/laravel-onedrive-filesystem
More information about kalprajsolutions/laravel-onedrive-filesystem
Files in kalprajsolutions/laravel-onedrive-filesystem
Package laravel-onedrive-filesystem
Short Description OneDrive filesystem driver for Laravel using Microsoft Graph API
License MIT
Informations about the package laravel-onedrive-filesystem
Laravel OneDrive Filesystem
Use Microsoft OneDrive for Business as a native Laravel filesystem disk. This package provides a drop-in OneDrive filesystem driver powered by the Microsoft Graph API with automatic token caching — no OAuth redirects, no manual token refresh, no boilerplate.
Works with Storage::disk('onedrive') exactly like local or S3 storage. Upload files, download files, manage directories, generate sharing URLs — all through Laravel's standard Storage facade.
Laravel 10, 11, and 12 supported. PHP 8.1+ required.
Why This Package?
There are other OneDrive adapters for Laravel, but most of them share the same problems:
- They require you to manually handle OAuth redirects and store access tokens yourself.
- They give you a Flysystem adapter you have to wire up with
Storage::build()instead of the familiarStorage::disk(). - They don't cache tokens, so every request hits Azure AD for a new token.
- They only support one account at a time.
This package fixes all of that. It registers as a real Laravel filesystem driver, caches tokens using Laravel's cache system, and supports multiple OneDrive accounts through multiple disk configurations. You install it, add your Azure AD credentials to .env, and start using Storage::disk('onedrive') — the same way you'd use any other Laravel storage disk.
How It Compares
| Feature | This Package | justus/flysystem-onedrive |
sahablibya/laravel-sharepoint-filesystem |
LLoadout/microsoftgraph |
|---|---|---|---|---|
Native Storage::disk('onedrive') |
✅ | ❌ (requires Storage::build()) |
✅ | ✅ |
| Client credentials auth (no OAuth redirect) | ✅ | ❌ (manual token required) | ✅ | ❌ |
| Automatic token caching | ✅ | ❌ | ✅ | ❌ |
| Multiple OneDrive accounts | ✅ | ❌ | ❌ | ❌ |
| Laravel 10 support | ✅ | ❌ | ✅ | ✅ |
| Laravel 12 support | ✅ | ✅ | ✅ | ✅ |
Scoped base path (GRAPH_BASE_PATH) |
✅ | ❌ | ❌ | ❌ |
| Pure OneDrive focus (no bloat) | ✅ | ✅ | ❌ (SharePoint included) | ❌ (Mail, Teams, Excel included) |
Who Is This For?
- You're building a Laravel app on a corporate Microsoft 365 tenant and want to store files on OneDrive for Business instead of (or alongside) S3 or local storage.
- You need a filesystem disk for Spatie Laravel Backup that lands on OneDrive.
- You want to give users file storage backed by OneDrive without building a custom OAuth flow.
- You're running automated jobs, cron commands, or queues that need to read/write OneDrive files without a browser-based login.
Installation
Install via Composer:
Publish the configuration file:
This creates config/onedrive.php in your application.
Configuration
Environment Variables
Add these to your .env file:
Filesystem Disk
Add the OneDrive disk to config/filesystems.php:
Multiple Accounts
You can configure multiple OneDrive disks for different accounts:
Azure AD App Registration
You need an Azure AD app registration with application permissions (not delegated). This is what allows the package to authenticate without a user login flow.
Step 1: Register the App
- Go to Azure Portal → Azure Active Directory → App registrations → New registration
- Name: your app name
- Supported account types: Accounts in this organizational directory only (Single tenant)
- Redirect URI: leave blank
- Click Register
Step 2: Collect Credentials
After registration, copy these values:
- Application (client) ID →
GRAPH_CLIENT_ID - Directory (tenant) ID →
GRAPH_TENANT_ID
Step 3: Create a Client Secret
- Go to Certificates & secrets → New client secret
- Add a description, pick an expiration, click Add
- Copy the secret value immediately (it won't be shown again) →
GRAPH_CLIENT_SECRET
Step 4: Add API Permissions
- Go to API permissions → Add a permission → Microsoft Graph → Application permissions
- Add:
Files.ReadWrite.All - Click Grant admin consent (requires admin role)
Step 5: Get the User ID
- Go to Graph Explorer
- Sign in and run the "my profile" query
- Copy the
idfrom the response →GRAPH_USER_ID// your email address also works
Usage
All standard Laravel filesystem methods work. Here are the most common operations:
Write and Read Files
Upload Files from Requests
Download Files
Check, Copy, Move, Delete
File Metadata
Directory Operations
Available Methods
| Method | Description |
|---|---|
put($path, $contents) |
Write content to a file |
putFile($path, $file) |
Upload a file |
putFileAs($path, $file, $name) |
Upload with a custom name |
get($path) |
Read file content |
readStream($path) |
Read file as a stream |
download($path, $name) |
Download as a response |
exists($path) |
Check if file exists |
delete($path) |
Delete a file |
copy($source, $destination) |
Copy a file |
move($source, $destination) |
Move / rename a file |
size($path) |
Get file size |
lastModified($path) |
Get last modified timestamp |
mimeType($path) |
Get MIME type |
files($directory) |
List files in a directory |
directories($directory) |
List directories |
allFiles($directory) |
List all files recursively |
allDirectories($directory) |
List all directories recursively |
createDirectory($path) |
Create a directory |
deleteDirectory($directory) |
Delete a directory |
getUrl($path) |
Get a sharing URL |
Spatie Laravel Backup
This package works as a backup destination for spatie/laravel-backup. Configure your backup disk:
Then run your backup as usual:
Token Caching
Access tokens are automatically cached using Laravel's default cache driver. You don't need to configure anything — the package handles token acquisition and refresh transparently. Make sure your cache driver is properly configured (Redis, Memcached, or database all work fine).
FAQ
What Laravel versions are supported?
Laravel 10, 11, and 12.
Can I use this with personal Microsoft accounts?
This package is built for OneDrive for Business (Microsoft 365 / organizational accounts). Personal Microsoft accounts (@outlook.com, @hotmail.com) may require additional configuration and are not officially supported.
How do I use a scoped base path?
Set GRAPH_BASE_PATH in your .env to a folder name. All file operations will be relative to that folder inside OneDrive. For example, GRAPH_BASE_PATH=MyApp means Storage::disk('onedrive')->put('file.txt', ...) writes to MyApp/file.txt in OneDrive.
Does this support large file uploads?
Yes. The adapter uses Microsoft Graph upload sessions for files that exceed the simple upload limit.
How do I get support?
Open an issue on GitHub or contact us through kalprajsolutions.com.
Changelog
See CHANGELOG.md for recent changes.
v1.1 — Added chunk upload support for files larger than 4 MiB via Microsoft Graph upload sessions.
Contributing
See CONTRIBUTING.md for details. Contributions, bug reports, and feature requests are welcome.
Security
If you discover a security vulnerability, please open an issue on GitHub or contact us through kalprajsolutions.com.
License
The MIT License (MIT). See LICENSE for details.
All versions of laravel-onedrive-filesystem with dependencies
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/filesystem Version ^10.0|^11.0|^12.0
league/flysystem Version ^3.0
guzzlehttp/guzzle Version ^7.0