1. Go to this page and download the library: Download laravel-bridge/slim library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
laravel-bridge / slim example snippets
use Slim\App;
$container = [
SomeClass::class => function() {},
]
$app = new App($container);
// Rename use class
use LaravelBridge\Slim\App;
use Slim\App;
use Slim\Container;
$container = new Container();
$container[SomeClass::class] = function() {};
$app = new App($container);
use LaravelBridge\Slim\ContainerBuilder;
use Slim\App;
$containerBuilder = new ContainerBuilder();
// Use builder mixin the Scratch Application / Laravel Container
$containerBuilder->singleton(SomeClass::class, function() {});
$containerBuilder->setupDatabase($conncetion)
->setupProvider(YourProvider::class);
// Register provider for Slim Framework
$containerBuilder
->useLaravelFoundHandler()
->useLaravelHttp();
// Build Container and bootstrap
$container = $containerBuilder->buildAndBootstrap();
$app = new App($container);
use LaravelBridge\Slim\ContainerBuilder;
use Slim\App;
use Slim\Container;
$slimContainer = new Container();
$slimContainer['foo'] = 'bar';
$containerBuilder = new ContainerBuilder($slimContainer);
// Build Container and bootstrap
$container = $containerBuilder->buildAndBootstrap();
$container->make('foo') // Will return 'bar'
use LaravelBridge\Slim\App;
$app = new App([], true);
use LaravelBridge\Slim\ContainerBuilder;
$app = new ContainerBuilder([], true);
$container = (new ContainerBuilder())
->useLaravelFoundHandler()
->buildAndBootstrap();
$app = new App($container);
$app->get('/', function (IlluminateRequest $request, $args) {
// Auto-inject Illuminate Request in clousre
});
class SomeController
{
public function __construct(Dep $dep) {}
public function __invoke() {}
public function view() {}
}
$container = (new ContainerBuilder())
->useLaravelCallableResolver()
->buildAndBootstrap();
$app = new App($container);
// Will call SomeController::__invoke()
$app->get('/', 'SomeController');
// Will call SomeController::view()
$app->get('/', 'SomeController:view');
$container = (new ContainerBuilder())
->setSettings(['foo' => 'bar'])
->useLaravelSettings()
->buildAndBootstrap();
// Return a Repository instance
$container->get('settings');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.