PHP code example of john-jun / container
1. Go to this page and download the library: Download john-jun/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/ */
john-jun / container example snippets
$container = new \Air\Container\Container();
$redis = new \Redis();
$container->singleton('obj', $redis);
$container->singleton('redis', \Redis::class);
$container->bind('name', function(\Redis $redis) {
return $redis;
}, true);
$container->get('obj');
$container->make('redis');
$container->make('name');
$container->make('obj name more');
$container->has('obj');
$container->alias('objAlias', 'obj');