graham-campbell/manager
Adds a reusable “manager” layer for Laravel packages and apps, helping you build driver-based services (create, cache, and resolve drivers) with a consistent API. Supports Laravel 8–13 and PHP 7.4–8.5.
Unified Connection Management for Custom Packages: Accelerates development of Laravel packages requiring multi-driver support (e.g., payment gateways, third-party APIs, storage adapters) by providing a batteries-included manager pattern. Eliminates boilerplate for connection pooling, dynamic extension, and config resolution, reducing time-to-market for internal tools or open-source contributions.
Laravel-Notion package where users can switch between Notion API v1/v2 or self-hosted instances via Manager::extend('notion', fn() => new NotionV2Client()).Modularization of Monolithic Services:
Enables decomposition of large service classes (e.g., AuthService) into driver-specific managers (e.g., OAuth2Manager, LDAPManager) while maintaining a consistent API surface. Critical for teams adopting microservices or domain-driven design in Laravel.
UserService → AuthManager + ProfileManager).Configuration-Driven Extensibility for SaaS Platforms:
Allows end-users to add custom integrations without code changes via Manager::extend(). Ideal for:
Manager::extend('stripe', fn() => new CustomStripeGateway())).Manager::extend('logging', fn() => new SplunkLogger())) for compliance or legacy system integration.Legacy System Migration: Facilitates gradual modernization of older Laravel packages (L5/L6) by providing a backward-compatible abstraction layer. Teams can incrementally adopt Laravel 10+ features while preserving existing driver logic.
Laravel-5.5 package to Laravel 11 by wrapping its Connection class in AbstractManager.Internal Tooling Standardization:
Reduces technical debt in shared libraries by enforcing a single pattern for connection management across teams. Example: Replace ad-hoc DatabaseManager clones in different repos with a corporate-wide ServiceManager base class.
Adopt When:
Look Elsewhere When:
spatie/laravel-activitylog or custom solutions).beyondcode/laravel-websockets instead)."This package lets us build and extend Laravel services faster by standardizing how we manage connections to external systems—like databases, APIs, or storage. Instead of writing custom connection logic for every new integration (e.g., a new payment gateway or cloud provider), we reuse a proven, lightweight framework that’s already used by packages like Laravel Flysystem. This reduces development time by 30–50% for multi-driver features and enables our SaaS customers to add their own integrations without code changes—a key differentiator for enterprise adoption. The MIT license and active maintenance (last update: March 2026) ensure long-term reliability."
*"Problem: Every time we add a new driver (e.g., a second payment processor or storage backend), we duplicate connection pooling, config resolution, and extension logic. This creates technical debt and slows down feature delivery.
Solution: Use graham-campbell/manager to inherit a battle-tested manager pattern from Laravel’s core. Key benefits:
Manager::extend()), and config resolution are built-in.DatabaseManager, CacheManager, etc., so your team won’t reinvent the wheel.Manager::extend('s3', fn() => new CustomS3Client())).AbstractManager. Example:class PaymentManager extends AbstractManager {
protected function createConnection(array $config) {
return new StripeClient($config['api_key']);
}
protected function getConfigName() { return 'payments'; }
}
Impact: Faster development, fewer bugs, and easier maintenance for multi-driver features."*
*"Need to manage multiple connections (e.g., databases, APIs, storage) in a Laravel package or app? This package gives you:
✅ Connection pooling: Reuse connections instead of recreating them.
✅ Dynamic extension: Add custom drivers runtime via Manager::extend().
✅ Magic methods: Call ->method() directly on the manager (e.g., ->upload() instead of ->connection()->upload()).
✅ Zero config: Just extend AbstractManager and implement two methods.
Example Use Cases:
Laravel-GitHub package with support for both REST and GraphQL APIs.AuthManager to support custom OAuth providers without modifying core files.
Get Started:composer require graham-campbell/manager
Docs: GitHub | Examples: Laravel Flysystem."*
How can I help you explore Laravel packages today?