问题:
我的 Laravel 5.2 应用程序出错,其中对类方法的调用导致 Laravel无法找到该类。
我运行一个灯堆。
我尝试了各种建议,许多人偶然发现了命名空间作为解决方案。我是 Laravel 的新手,所以可能有一些我做错了的元素设置。我主要研究了文件夹所有权和权限。
在调用库提供的不同控制器时,我也遇到了这个问题。但是,我不确定描述这个问题是否只会混淆真正的问题。
我的错误:
路由中的反射异常.php第 264 行:类应用程序''Http''控制器''SteamInventory 不存在
- 在路线.php 264路
- 在ReflectionMethod->__construct('App''Http''Controllers''SteamInventory',"获取库存"),在路线.php第 264 行
- at Route->signatureParameters('Illuminate''Database''Eloquent''Model')在路由器中.php第 859 行
- at Router->substituteImplicitBindings(object(Route)) in Router.php844路
- 在路由器中的 Router->substituteBindings(object(Route).php第 827 行
- 在路由器中>查找路由(对象(请求)).php第 691 行
- 在路由器中的 Router->dispatchToRoute(object(Request).php第 675 行
- 在内核中的路由器>调度(对象(请求)).php第 246 行
- at Kernel->Illuminate''Foundation''Http{closure}(object(Request))
- 在管道中的call_user_func(对象(闭包),对象(请求).php 52号线
- at Pipeline->Illuminate''Routing{closure}(object(Request)) in 检查维护模式.php第 44 行
- at CheckForMaintenanceMode->handle(object(Request), 对象(闭包))
- at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php 124路
- at Pipeline->Illuminate''Pipeline{closure}(object(Request))
- 在管道中的call_user_func(对象(闭包),对象(请求).php 32号线
- at Pipeline->Illuminate''Routing{closure}(object(Request))
- 在管道中的call_user_func(对象(闭包),对象(请求).php 103路
- 在内核中的 Pipeline->then(object(Closure).php第 132 行
- at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php 99路
- 在索引中的内核->句柄(对象(请求).php第 54 行
我在/app/Http/routes 中的路由.php
Route::group(['middleware' => ['auth']], function () {
Route::get('trades', 'SteamInventory@getInventory');
});
我在/app/Http/Controllers/SteamInventoryController 中的控制器.php
<?php
namespace App'Http'Controllers;
use Illuminate'Http'Request;
use App'Http'Requests;
class SteamInventoryController extends Controller
{
public function getInventory () {
return "test";
}
}
更改此内容
SteamInventory
对此
SteamInventoryController
在此
Route::get('trades', 'SteamInventory@getInventory');
更改路线
Route::get('trades', 'SteamInventory@getInventory');
自
Route::get('trades', 'SteamInventoryController@getInventory');