- Is php-di/slim-bridge a Laravel package?
- No. It is a thin adapter that connects the PHP-DI PSR-11 container to Slim 4's AppFactory. Laravel already ships an autowiring container with service providers, facades, and contextual binding, so this bridge has no role inside a Laravel application. Treat it as Slim-only plumbing.
- How do I install and wire php-di/slim-bridge in a Slim 4 app?
- Install it with composer require php-di/slim-bridge, then build a PHP-DI container with ContainerBuilder and pass it to Slim via AppFactory::setContainer() before creating the app. From there Slim resolves route callables, middleware, and error handlers through the container. The integration is small and typically takes hours, not weeks.
- Does php-di/slim-bridge work with Laravel or Lumen?
- It does not target Laravel or Lumen; it is built for Slim 4. Laravel's container already handles autowiring, bindings, and contextual resolution, so adding this bridge would introduce a second DI idiom for no benefit. If you are evaluating it as a lighter Laravel alternative, reject that use case and keep Laravel conventions.
- Which Slim and PHP-DI versions does php-di/slim-bridge support?
- The bridge is Slim 4-only and tracks PHP-DI 7.x. That means Slim 3 services must first upgrade to Slim 4 before adopting it, and a future Slim 5 or PHP-DI 8 release may create a compatibility lag window. Pin your supported version matrix and watch upstream releases.
- How does autowiring work for Slim route controllers with PHP-DI?
- Slim asks the injected PSR-11 container to resolve route callables, middleware, and error handlers, so PHP-DI can constructor-inject dependencies instead of you pulling them from a global container. You define autowiring, aliases, and lazy services in PHP-DI configuration or attributes. Resolution happens at runtime, so misconfiguration appears as an exception when the route is hit.
- Can I use php-di/slim-bridge with an existing Slim 3 application?
- Not directly. The bridge integrates with Slim 4's AppFactory, so a Slim 3 service must complete the framework upgrade to Slim 4 first. Sequence the work as Slim 3 to Slim 4 as an independent upgrade, then adopt the bridge as a container cleanup step.
- How do I test PHP-DI container configuration in a Slim app to catch autowiring errors?
- Because autowiring failures surface as runtime resolution exceptions rather than boot-time failures, add explicit container smoke tests that compile the container and resolve key controllers, middleware, and error handlers in CI. That catches missing definitions before deployment. Keep the tests close to route registration so drift is visible.
- What are the alternatives to php-di/slim-bridge for dependency injection in Slim 4?
- You can wire any PSR-11 container into Slim 4 yourself via AppFactory::setContainer(), or use PHP-DI directly with your own bootstrap. The bridge's value is the thin, maintained glue between PHP-DI and Slim. Inside Laravel, the correct alternative is Laravel's built-in container and service providers.
- Is php-di/slim-bridge production-ready and actively maintained?
- The code risk is low: it is small, MIT-licensed glue with a recent release and active upstream ecosystems in PHP-DI and Slim. The risks are version-matrix drift, no commercial support, and vendor concentration around a small maintainer base. Treat it as tactical plumbing and be prepared to vendor-fork if upstream stalls.
- Does php-di/slim-bridge support PSR-15 middleware and PSR-7 requests?
- Yes. The bridge is PSR-11-native and composes with PSR-7 HTTP messages and PSR-15 middleware, so Slim's middleware pipeline can resolve dependencies through PHP-DI. That makes it suitable for narrow services such as webhook receivers, BFF endpoints, and lightweight internal APIs.