Illuminate (Laravel) Container integration in Slim
p7v/illuminate-container-slim-bridge is a Laravel package for illuminate (laravel) container integration in slim.
It currently has 0 GitHub stars and 79 downloads on Packagist (latest version 1.1.2).
Install it with composer require p7v/illuminate-container-slim-bridge.
Discover more Laravel packages by p7v
or browse all Laravel packages to compare alternatives.
Last updated
This package configures Slim to work with the Illuminate container. By default, container supports autowiring.
composer require p7v/illuminate-container-slim-bridge
Instead of using the official Slim\Factory\AppFactory, use Bridge class to create your application:
<?php
require 'vendor/autoload.php';
$app = \P7v\IlluminateContainerSlim\Bridge::create();
If you need to configure the container beforehand, pass your configured container to the method:
<?php
require 'vendor/autoload.php';
$container = new \Illuminate\Container\Container();
/** Configure your container */
$app = \P7v\IlluminateContainerSlim\Bridge::create($container);
You can use service providers for container configuration. Your service provider has to extend P7v\IlluminateContainerSlim\ServiceProvider. Then provide list of names of your service providers to usingProviders method in Bridge.
class AppServiceProvider extends \P7v\IlluminateContainerSlim\ServiceProvider
{
public function register(): void
{
$this->bind('key', function () {
return new stdClass();
});
$this->singleton(RepositoryInterface::class, Repository::class);
}
}
<?php
require 'vendor/autoload.php';
$providers = [
AppServiceProvider::class,
];
$app = \P7v\IlluminateContainerSlim\Bridge::usingProviders($providers);