bridgekit-tools/bridgekit-lib
Composer 安装命令:
composer require bridgekit-tools/bridgekit-lib
包简介
A Laravel library for managing third-party provider integrations (Google, Microsoft, Meta, LinkedIn, X)
README 文档
README
BridgeKit
Universal Laravel Integration Library
One library to connect Google, Microsoft, Meta, LinkedIn & X.
What is BridgeKit?
BridgeKit is a Laravel library that provides a unified, typed API for integrating with third-party providers. Instead of learning 5 different SDKs, you learn one interface.
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')], ) );
Features
- 5 providers — Google, Microsoft, Meta, LinkedIn, X
- 15 services — Drive, OneDrive, Gmail, Outlook, Calendar (×2), Posts (×3), OAuth (×5)
- 6 contracts — Swap providers without changing your code
- Typed DTOs —
final readonlyclasses withJsonSerializable - 7 enums —
Provider,MediaType,Visibility,EventStatus,MailFolder,OAuthGrantType,ServiceType - Streaming — Zero-memory downloads via
downloadStream() - Chunked uploads — Resumable uploads for files of any size
- Lazy generators — Memory-efficient paginated listing
- Media support — Upload images & videos from URL, path, or binary
- PKCE — Built-in for X/Twitter OAuth 2.0
- Extensible — Register custom providers via
extend()
Requirements
- PHP 8.3+
- Laravel 13+
Installation
composer require bridgekit-tools/bridgekit-lib
The service provider and facade are auto-discovered. Publish the config:
php artisan vendor:publish --tag=bridgekit-config
Configuration
Add credentials to your .env:
# Google BRIDGEKIT_GOOGLE_CLIENT_ID= BRIDGEKIT_GOOGLE_CLIENT_SECRET= BRIDGEKIT_GOOGLE_REDIRECT_URI= # Microsoft BRIDGEKIT_MICROSOFT_CLIENT_ID= BRIDGEKIT_MICROSOFT_CLIENT_SECRET= BRIDGEKIT_MICROSOFT_REDIRECT_URI= BRIDGEKIT_MICROSOFT_TENANT=common # Meta BRIDGEKIT_META_CLIENT_ID= BRIDGEKIT_META_CLIENT_SECRET= BRIDGEKIT_META_REDIRECT_URI= # LinkedIn BRIDGEKIT_LINKEDIN_CLIENT_ID= BRIDGEKIT_LINKEDIN_CLIENT_SECRET= BRIDGEKIT_LINKEDIN_REDIRECT_URI= # X (Twitter) BRIDGEKIT_X_CLIENT_ID= BRIDGEKIT_X_CLIENT_SECRET= BRIDGEKIT_X_REDIRECT_URI=
Quick Start
OAuth Flow
// 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();
File Storage
$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; }
Folders & files as a tree
Every storage provider exposes listTree() which returns a recursive
StorageTreeNode. It can be JSON-serialised, walked depth-first, or rendered
as ASCII for logs/debug output.
$tree = BridgeKit::s3()->storage()->listTree('photos/', [ 'max_depth' => 3, 'include_files' => true, ]); echo $tree->toAscii(); // photos/ // ├── 2025/ // │ ├── team.jpg // │ └── 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; } }
SharePoint document libraries
$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();
Required Graph scopes (delegated): Sites.Read.All, Files.ReadWrite.All.
Social Publishing
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: ['user@example.com'], isHtml: true, ));
Calendar
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: ['alice@company.com'], ) );
Custom Providers
use BridgeKit\Support\AbstractProvider; class DropboxProvider extends AbstractProvider { public function getName(): string { return 'dropbox'; } // ... implement services } // Register BridgeKit::extend('dropbox', DropboxProvider::class);
Available Services
| Provider | Storage | Calendar | Social | OAuth | |
|---|---|---|---|---|---|
drive() |
gmail() |
calendar() |
— | auth() |
|
| Microsoft | onedrive(), sharepoint() |
outlook() |
calendar() |
— | auth() |
| Meta | — | — | — | posts() |
auth() |
| — | — | — | posts() |
auth() |
|
| X | — | — | — | posts() |
auth() |
| Dropbox | storage() |
— | — | — | auth() |
| S3 (AWS, MinIO, R2, …) | storage() |
— | — | — | — |
| FTP / FTPS | storage() |
— | — | — | — |
| SFTP | storage() |
— | — | — | — |
Architecture
src/
├── Contracts/ # Interfaces (FileStorage, Email, Calendar, Social, OAuth)
├── DTOs/ # Typed value objects (OAuthToken, StorageFile, MediaContent, ...)
├── Enums/ # Provider, MediaType, Visibility, EventStatus, ...
├── Exceptions/ # BridgeKitException, AuthenticationException, ...
├── Providers/ # Google, Microsoft, Meta, LinkedIn, X
│ └── */Services/ # Concrete implementations
├── Support/ # AbstractProvider, AbstractService, ConnectManager
├── Concerns/ # HasHttpClient trait
├── Facades/ # BridgeKit facade
└── BridgeKitServiceProvider.php
Testing
composer test
101 tests, 276 assertions.
Changelog
See CHANGELOG.md for recent changes.
License
The MIT License (MIT). See LICENSE for details.
bridgekit-tools/bridgekit-lib 适用场景与选型建议
bridgekit-tools/bridgekit-lib 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 5, 最近一次更新时间为 2026 年 04 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「oauth」 「google」 「social」 「linkedin」 「laravel」 「microsoft」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bridgekit-tools/bridgekit-lib 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bridgekit-tools/bridgekit-lib 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bridgekit-tools/bridgekit-lib 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
WeChat OAuth SDK
Simple Sharing generates social media share links within CP entry pages, allowing you to quickly & easily share entries.
Ory-Hydra OAuth 2.0 Client Provider for The PHP League OAuth2-Client
Library for ORCID web services
A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.
LinkedIn integration for Social
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 45
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-01