PHP code example of godruoyi / easy-container

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

    

godruoyi / easy-container example snippets


class Cache
{
    public function __construct(Config $config){}
}

class Config
{
}

// not support
$cache = $container->make('Cache');

$app = new Godruoyi\Container\Container;

$app->bind('HelpSpot\API', function ($app) {
    return new HelpSpot\API($app->make('HttpClient'));
});

$app->singleton('HelpSpot\API', function ($app) {
    return new HelpSpot\API($app->make('HttpClient'));
});


// Automatically parses the dependencies er::class);

class UserController
{
    public function __construct(UserRepository $users, HttpClient $client, $other = 'default')
    {
    }
}