PHP code example of bridgekit-tools / bridgekit-lib

1. Go to this page and download the library: Download bridgekit-tools/bridgekit-lib 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/ */

    

bridgekit-tools / bridgekit-lib example snippets


use BridgeKit\Facades\BridgeKit;

// Google Drive
$files = BridgeKit::google()->setToken($token)->drive()->listFiles();

// Microsoft OneDrive — same interface
$files = BridgeKit::microsoft()->setToken($token)->onedrive()->listFiles();

// Post to LinkedIn with media
$result = BridgeKit::linkedin()->setToken($token)->posts()->publish(
    new SocialPost(
        content: 'Hello from BridgeKit!',
        media: [MediaContent::fromUrl('https://example.com/photo.jpg')],
    )
);

// 1. Redirect to consent screen
$url = BridgeKit::google()->auth()->getAuthorizationUrl([
    'https://www.googleapis.com/auth/drive.readonly',
]);
return redirect($url);

// 2. Handle callback
$token = BridgeKit::google()->auth()->handleCallback($request->code);

// 3. Use services
$google = BridgeKit::google()->setToken($token);
$files = $google->drive()->listFiles();
$events = $google->calendar()->listEvents();

$drive = BridgeKit::google()->setToken($token)->drive();

$files = $drive->listFiles();
$file = $drive->uploadFile('doc.txt', 'Hello world', 'text/plain');
$stream = $drive->downloadStream('file-id');

// Large file upload (chunked, resumable)
$file = $drive->uploadLargeFile('backup.zip', '/path/to/file.zip', 'application/zip');

// Memory-efficient listing
foreach ($drive->listFilesLazy() as $file) {
    echo $file->name;
}

$tree = BridgeKit::s3()->storage()->listTree('photos/', [
    'max_depth' => 3,
    'g
// │   └── trip.jpg
// └── logo.png

echo $tree->countDescendants(); // 4
echo $tree->totalSize();        // cumulative bytes

foreach ($tree->walk() as $node) {
    if ($node->isFile()) {
        echo $node->file->webUrl;
    }
}

$sp = BridgeKit::microsoft()->setToken($token)->sharepoint([
    'site_path' => '/contoso.sharepoint.com:/sites/marketing',
    // 'drive_id' => '...', // optional, defaults to the site's Documents library
]);

$tree = $sp->listTree();
$file = $sp->uploadLargeFile('campaign.pdf', '/local/campaign.pdf', 'application/pdf');
$libraries = $sp->listLibraries();

use BridgeKit\DTOs\{SocialPost, MediaContent};
use BridgeKit\Enums\Visibility;

$result = BridgeKit::x()->setToken($token)->posts()->publish(
    new SocialPost(
        content: 'Posted via BridgeKit!',
        media: [
            MediaContent::fromUrl('https://example.com/photo.jpg', altText: 'A photo'),
            MediaContent::fromPath('/local/video.mp4'),
        ],
        visibility: Visibility::Public,
    )
);

echo $result->url;

use BridgeKit\DTOs\EmailMessage;

BridgeKit::google()->setToken($token)->gmail()->send(new EmailMessage(
    subject: 'Welcome',
    body: '<h1>Hello!</h1>',
    to: ['[email protected]'],
    isHtml: true,
));

use BridgeKit\DTOs\CalendarEvent;

$event = BridgeKit::google()->setToken($token)->calendar()->createEvent(
    new CalendarEvent(
        title: 'Team Standup',
        startAt: new DateTimeImmutable('2026-04-01T09:00:00'),
        endAt: new DateTimeImmutable('2026-04-01T09:30:00'),
        timezone: 'Europe/Paris',
        attendees: ['[email protected]'],
    )
);

use BridgeKit\Support\AbstractProvider;

class DropboxProvider extends AbstractProvider
{
    public function getName(): string { return 'dropbox'; }
    // ... implement services
}

// Register
BridgeKit::extend('dropbox', DropboxProvider::class);
bash
php artisan vendor:publish --tag=bridgekit-config