尝试使用 DatabaseServiceProvider 中单例创建的 ConnectionFactory class
Trying to use the ConnectionFactory class created by singleton in DatabaseServiceProvider
所以 Tapestry 有它的默认值 DatabaseServiceProvider.php,里面有下面的代码。
$this->app->singleton('db.factory', function ($app) {
return new ConnectionFactory($app);
});
我希望能够使用由此创建的 db.factory 外观来建立新连接。但是当我打电话给
db.factory::make($config,$factory);
当然这不行,我得到一个错误:
Use of undefined constant db - assumed 'db'
我该怎么做?
必须通过 service container 直接访问该单例。我最喜欢的方法是 app()
辅助函数:
app('db.factory')->make($config, $factory);
所以 Tapestry 有它的默认值 DatabaseServiceProvider.php,里面有下面的代码。
$this->app->singleton('db.factory', function ($app) {
return new ConnectionFactory($app);
});
我希望能够使用由此创建的 db.factory 外观来建立新连接。但是当我打电话给
db.factory::make($config,$factory);
当然这不行,我得到一个错误:
Use of undefined constant db - assumed 'db'
我该怎么做?
必须通过 service container 直接访问该单例。我最喜欢的方法是 app()
辅助函数:
app('db.factory')->make($config, $factory);