首页 > 解决方案 > 在 Laravel 控制器中找不到 PHP 类

问题描述

我在 Laravel 控制器中遇到问题,我不确定从哪里开始进行故障排除。基本上 2 个单独的方法正在调用同一个外部类;该process方法有效,但是在调用时process3d我遇到了错误class 'App\Services\PaymentGateway\Gateway\RequestGatewayEntryPointList' not found.

调试控制器.php

namespace App\Http\Controllers;
use App\Services\PaymentGateway\Gateway\RequestGatewayEntryPointList;
...
public function process(Request $request) {
   ...
   $rgeplRequestGatewayEntryPointList = new RequestGatewayEntryPointList;
   ...
}

public function process3d(Request $request) {
   ...
   $rgeplRequestGatewayEntryPointList = new RequestGatewayEntryPointList;
   ...
}

支付系统.php

namespace App\Services\PaymentGateway\Gateway;
...
class RequestGatewayEntryPointList {
   ...
}

我省略了不相关的代码以保持问题简短,但如果有帮助,我当然很乐意提供更多详细信息。

这是怎么回事?

标签: phplaravelnamespaces

解决方案


发布到 stackoverflow 后 5 分钟找到它......哎呀。

process3d 缺少 require_once DIR .'/../../Services/PaymentGateway/Gateway/PaymentSystem.php';

添加这个解决了这个问题。


推荐阅读