- How do I install graham-campbell/manager in a Laravel project?
- Run `composer require graham-campbell/manager` to install the package. It supports Laravel 8–13 and PHP 7.4–8.5. No additional configuration is required unless you need custom drivers or facades, which can be set up via the `config/manager.php` file.
- Can I use Laravel Manager for payment gateways like Stripe or PayPal?
- Yes, Laravel Manager is perfect for payment gateways. Define drivers in your config, then resolve them via `Manager::connection('stripe')` or `Manager::connection('paypal')`. The package supports lazy resolution and caching for performance.
- Does Laravel Manager support runtime driver extension (e.g., adding a custom driver without code changes)?
- Absolutely. Use `Manager::extend('driver_name', CustomDriver::class)` to register drivers dynamically. This is ideal for plugins, SaaS multi-tenancy, or third-party integrations without modifying core code.
- How do I mock or fake connections for testing?
- Laravel Manager provides `Manager::fake()` for testing. You can also use `Manager::shouldReceive()` with Mockery to stub method calls. This works seamlessly with Laravel’s testing tools like `HttpTests` or `FeatureTests`.
- Is Laravel Manager compatible with Laravel 5.x packages?
- While the package officially supports Laravel 8–13, you can wrap older Laravel 5/6 packages in a Manager-compatible facade. Type hints may need adjustments, but the core abstraction remains compatible with modern Laravel conventions.
- Can I use Laravel Manager for stateful connections like WebSocket streams?
- Laravel Manager is optimized for stateless operations (e.g., API calls, database queries). For stateful connections like WebSockets, consider pairing it with Laravel’s event system or a dedicated connection manager to avoid leaks.
- How do I handle configuration validation for drivers?
- The package relies on Laravel’s config system, so invalid configs (e.g., missing API keys) may cause silent failures. Add validation in your driver’s `createConnection()` method or use Laravel’s `ValidatedConfig` trait to enforce rules.
- Does Laravel Manager support async drivers (e.g., Guzzle HTTP clients with async-await)?
- No, it lacks native async support. For async drivers, wrap them in a library like `spatie/async` or use `Manager::extend('http', fn() => new AsyncClient())` to integrate with Laravel’s async tools.
- What are the performance implications of connection pooling?
- Connection pooling improves performance for stateless operations by reusing instances. However, for high-throughput services, stale connections may cause issues. Use `Manager::reconnect()` or Laravel’s `app()->flush()` to manage connection lifecycles.
- Are there alternatives to Laravel Manager for driver-based architectures?
- Alternatives include Laravel’s built-in managers (e.g., `CacheManager`, `FilesystemManager`) or third-party packages like `spatie/laravel-activitylog` for auditing. However, Laravel Manager offers a lightweight, reusable abstraction tailored for custom driver systems without bloat.