geekcell/container-facade
Laravel package that adds lightweight container-backed facades, letting you resolve services from the IoC container via a simple static-like interface. Useful for organizing service access and reducing boilerplate when binding and retrieving dependencies.
Cache::store(), Auth::user()), but these are dynamically resolved via the container. This package forces a static facade pattern, which can conflict with Laravel’s dynamic resolution and testing paradigms.Route, DB) may conflict with custom static facades if naming conventions overlap.Mockery or PHPUnit), complicating unit testing.Why Static Facades?
app()->make()) cannot?Compatibility
when() conditions)?Maintenance Burden
Testing Strategy
Alternatives
app()->make() achieve the same goal with less risk?Laravel\Container\Container::getInstance() or custom resolvers)?Logger service) and test integration with:
app()->make('logger')) with static facades (e.g., LoggerFacade::info()).register()).Auth).when()/needs() binding syntax.config/app.php) to reflect new facade aliases if needed.app()->make() calls).partialMock()).LoggerFacade::error() will show as LoggerFacade without method resolution).Undefined service exceptions in production).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Container not initialized | Undefined service errors |
Ensure facades are only called post-bootstrap. |
| Naming conflicts with Laravel facades | Overwritten or broken core features | Use unique namespace prefixes (e.g., App\Facades\). |
| Laravel version incompatibility | Silent failures or crashes | Pin package version and test on target Laravel version. |
| Testing gaps | Untestable static dependencies | Adopt partial mocking or refactor to DI. |
| Package abandonment | Unpatched security/bug risks | Fork and maintain internally if critical. |
composer.json aliases).How can I help you explore Laravel packages today?