绑定到单例,Aliases和实例
public function register() {
$this->app->singleton(Logger::class, function () {
return new Logger('\log\path\here', 'error');
});
}public function register() {
$logger = new Logger('\log\path\here', 'error');
$this->app->instance(Logger::class, $logger);
}// Asked for Logger, give FirstLogger
$this->app->bind(Logger::class, FirstLogger::class);
// Asked for log, give FirstLogger
$this->app->bind('log', FirstLogger::class);
// Asked for log, give FirstLogger
$this->app->alias(FirstLogger::class, 'log');Last updated