首页 > 解决方案 > Laravel 5.8 - 未执行单例方法

问题描述

我正在使用单例函数在 Laravel 5.8 中执行自定义类。下面是我的代码

 $this->app->singleton(CustomClass::class, function($app) {
        $action = new CustomClass();
        return $action->someMethod();
    });

但是,我的类既没有初始化,也没有调用我的方法。请帮忙

标签: phplaravellaravel-5.8

解决方案


推荐阅读