其中一个 service 类总是报 class not found 错误

最近新增了一个service类,报错:Class 'app\Services\SuspendService' not found。同目录中的其他service类运行正常。把我能想到的检查都做了,依然报错,请问下还有那些地方可能存在问题的:

1、用搜索方式检查类名,

2、更换使用方式,即注入方式和手工 new 的方式

3、逐步精简service类的代码,直至如下。

4、删除文件,重新创建: touch app/Services/SuspendService.php

5、从正常文件中复制下面代码的内容

6、Controller 类中去掉 Service 类后,Controller 类运行正常。

7、全文搜索正常的 service 类,查看是否有系统文件中有设置或者啥定义的地方,没找到奇怪的地方。

use app\Services\SuspendService;
class SuspendsController extends Controller
{
    protected $suspendService;
    // 1、注入方式
    // public function __construct(SuspendService $suspendService)
    // {
    //     $this->suspendService = $suspendService;
    // }

    public function update(Request $request){
        //2、手工new的方式
        $service = new SuspendService();
    }
}
<?php
namespace App\Services;
class SuspendService
{
    public function __construct(){

    }
}
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
leo
最佳答案

app\Services\SuspendService A 要大写

4年前 评论
t996523812 (楼主) 4年前
讨论数量: 1
leo

app\Services\SuspendService A 要大写

4年前 评论
t996523812 (楼主) 4年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!