PHP code example of flexsounds / slim-symfony-di-container
1. Go to this page and download the library: Download flexsounds/slim-symfony-di-container 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/ */
flexsounds / slim-symfony-di-container example snippets
$container = new \Flexsounds\Component\SymfonyContainerSlimBridge\ContainerBuilder();
$app = new \Slim\App($container);
// define your routes here. The container is available through $this in the route closure
$app->run();
$container = new \Flexsounds\Component\SymfonyContainerSlimBridge\ContainerBuilder();
$loader = new \Symfony\Component\DependencyInjection\Loader\YamlFileLoader($container, new \Symfony\Component\Config\FileLocator(__DIR__));
$loader->load('config.yml');
$app = new \Slim\App($container);
$app->run();
$app->get('/', function($request, $response){
$customService = $this->get('my.custom.service'); // $customService is now an instance of Location\To\The\Class()
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.