kekalainen / slim-illuminate-autowire
1.0.0
2022-11-27 16:56 UTC
Requires
- illuminate/container: >=4.0
- slim/slim: >=4.0
README
Autowire class dependencies using the Laravel/Illuminate service container by proxying Slim's callable resolver.
Usage
use Illuminate\Container\Container; use Illuminate\Contracts\Container\Container as ContainerContract; use Kekalainen\SlimIlluminateAutowire\AdvancedCallableResolverProxy; use Slim\CallableResolver; use Slim\Factory\AppFactory; use Slim\Interfaces\AdvancedCallableResolverInterface; // Instantiate the Illuminate container. $container = new Container(); // Bind the container instance into the container. $container->instance(ContainerContract::class, $container); // Bind a concrete advanced callable resolver to be proxied. $container->bind(AdvancedCallableResolverInterface::class, CallableResolver::class); // Resolve the proxied callable resolver. $callableResolver = $container->make(AdvancedCallableResolverProxy::class); // Set the static properties of the Slim App factory. AppFactory::setContainer($container); AppFactory::setCallableResolver($callableResolver); // Instantiate the Slim App. $app = AppFactory::create();