PHP code example of valter-medeiros / laravel-sharepoint

1. Go to this page and download the library: Download valter-medeiros/laravel-sharepoint library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

valter-medeiros / laravel-sharepoint example snippets


'disks' => [
    // ... other disks

    'sharepoint' => [
        'driver' => 'sharepoint',
        'tenant_id' => env('SHAREPOINT_TENANT_ID'),
        'client_id' => env('SHAREPOINT_CLIENT_ID'),
        
        // Use EITHER client_secret OR certificate_path
        'client_secret' => env('SHAREPOINT_CLIENT_SECRET'), 
        
        // Certificate Authentication (Recommended for production)
        'certificate_path' => env('SHAREPOINT_CERTIFICATE_PATH'), // Path to .pfx or .pfx.enc
        'certificate_password' => env('SHAREPOINT_CERTIFICATE_PASSWORD'), // Password for the .pfx
        
        // Optional Configuration
        'drive_id' => env('SHAREPOINT_DRIVE_ID'), // Specific drive ID. If null, uses the default drive.
        'prefix' => env('SHAREPOINT_PREFIX', ''), // Optional path prefix
    ],
],

use Illuminate\Support\Facades\Storage;

// Write a file
Storage::disk('sharepoint')->put('reports/2026/summary.pdf', $pdfContent);

// Read a file
$content = Storage::disk('sharepoint')->get('reports/2026/summary.pdf');

// Check if a file exists
if (Storage::disk('sharepoint')->exists('reports/2026/summary.pdf')) {
    // ...
}

// Delete a file
Storage::disk('sharepoint')->delete('reports/2026/summary.pdf');

// List files in a directory
$files = Storage::disk('sharepoint')->files('reports/2026');

// Create a directory
Storage::disk('sharepoint')->makeDirectory('reports/2027');
bash
php artisan sharepoint:list-drives
bash
php artisan sharepoint:list-drives --search="ADSR_Cloud"
bash
php artisan sharepoint:list-folders
bash
php artisan sharepoint:list-folders --search="My Folder"
php artisan sharepoint:list-folders --path="Shared Documents/2026"