PHP code example of starbug / di

1. Go to this page and download the library: Download starbug/di 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/ */

    

starbug / di example snippets




// You now have a Psr\Container\ContainerInterface instance
$application = $container->make("MyApp");

use Starbug\DI\ContainerFactory;

ithDefaultHandler()
  ->create();

// You now have a Psr\Container\ContainerInterface instance
$application = $container->make("MyApp");

use Starbug\DI\ContainerFactory;

$container = ContainerFactory::withHandlers(
  new MyHandler(),
  new SecondHandler()
)->create();

use Starbug\DI\ContainerFactory;

$factory = new ContainerFactory();
$factory->addHandler(new MyHandler());
$container = $factory->create();

return [
  "MyApp" => function () {
    $app = new MyApp();
    $app->addMiddleware(new MyMiddleware());
    return $app;
  }
];