p7v/illuminate-container-slim-bridge

Illuminate (Laravel) Container integration in Slim
86
Install
composer require p7v/illuminate-container-slim-bridge
Latest Version:1.1.2
PHP:^7.3 || ~8.0.0 || ~8.1.0
License:MIT
Last Updated:Jan 1, 2023
Links: GitHub  ·  Packagist
Maintainer: alexsoft

Illuminate container integration with Slim

Packagist Version

This package configures Slim to work with the Illuminate container. By default, container supports autowiring.

Install

composer require p7v/illuminate-container-slim-bridge

Minimal setup

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();

Setup with preconfigured container

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);

Configure container using service providers

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);

Related Packages

zizaco/entrust

This package provides a flexible way to add Role-based Permissions to Laravel. S...

5,352,808 6,006
leroy-merlin-br/mongolid-laravel

Easy, powerful and ultrafast MongoDB ODM for Laravel.

28,559 237
zizaco/testcases-laravel

Some classes to help write tests for laravel 4 applications

50,506 46
shiftonelabs/laravel-sqs-fifo-queue

Adds a Laravel queue driver for Amazon SQS FIFO queues.

6,930,980 154
itsgoingd/clockwork

php dev tools in your browser

30,454,975 5,945