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.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-onedrive-filesystem

Logo for Laravel Onedrive Filesystem

Latest Version on Packagist Total Downloads License PHP Version

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:

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?


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

  1. Go to Azure PortalAzure Active DirectoryApp registrationsNew registration
  2. Name: your app name
  3. Supported account types: Accounts in this organizational directory only (Single tenant)
  4. Redirect URI: leave blank
  5. Click Register

Step 2: Collect Credentials

After registration, copy these values:

Step 3: Create a Client Secret

  1. Go to Certificates & secretsNew client secret
  2. Add a description, pick an expiration, click Add
  3. Copy the secret value immediately (it won't be shown again) → GRAPH_CLIENT_SECRET

Step 4: Add API Permissions

  1. Go to API permissionsAdd a permissionMicrosoft GraphApplication permissions
  2. Add: Files.ReadWrite.All
  3. Click Grant admin consent (requires admin role)

Step 5: Get the User ID

  1. Go to Graph Explorer
  2. Sign in and run the "my profile" query
  3. Copy the id from 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

PHP Build Version
Package Version
Requires php Version ^8.1
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
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kalprajsolutions/laravel-onedrive-filesystem contains the following files

Loading the files please wait ...