php - Laravel 5.8 - 未执行单例方法
问题描述
我正在使用单例函数在 Laravel 5.8 中执行自定义类。下面是我的代码
$this->app->singleton(CustomClass::class, function($app) {
$action = new CustomClass();
return $action->someMethod();
});
但是,我的类既没有初始化,也没有调用我的方法。请帮忙
解决方案
推荐阅读
- r - 增加ggplot2中图例键之间的垂直间距
- go-gorm - Golang - GORM 如何为现有表创建模型?
- audio - 正确的 WAVE_FORMAT_1S16 PCM 双通道格式?
- python - Django admin:根据另一个字段的值显示模型的字段
- python - 如何在 Kivy 中从 python 代码更改屏幕
- javascript - 意外的令牌“导出”
- functional-programming - 将包括列表在内的多个参数传递给函数
- python - 如何仅使用numpy python中的矩阵运算(无for循环)计算两个矩阵之间的欧几里得距离?
- swiftui - SwiftUI 请求将 App 更新到最新版本
- reactjs - React/Leaflet-side-by-side 错误:地图容器已经初始化。#35