PHP code example of mongdch / mon-container
1. Go to this page and download the library: Download mongdch/mon-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/ */
mongdch / mon-container example snippets
$container = \mon\factory\Container::instance();
// 绑定对象
$container->bind('test', Test::class);
// 静态绑定服务
Container::set('demo2', A::class);
$exists = $container->has('demo');
var_dump($exists);
// 获取实例或者结果集
$ret = $container->make('demo');
var_dump($ret);
$class = $container->make('test');
var_dump($class->say());
// 静态获取实例或者结果集
$ret2 = Container::get('demo');
var_dump($ret2);