2
votes

The problem:

I have an error with my Laravel 5.2 application, where a call for a class method results in Laravel not being able to locate the class.

I run a LAMP-stack.

I have tried various suggestions, with many people stumbling upon namespacing as the solution. I am new to Laravel, so there might be some elemental setup that I have done incorrectly. I have mainly looked into folder ownership and permissions.

I have also experienced this problem when calling a different controller provided by a library. However, I am not certain whether or not describing this problem would just obfuscate the real issue.

My error:

ReflectionException in Route.php line 264: Class App\Http\Controllers\SteamInventory does not exist

  1. in Route.php line 264
  2. at ReflectionMethod->__construct('App\Http\Controllers\SteamInventory', 'getInventory') in Route.php line 264
  3. at Route->signatureParameters('Illuminate\Database\Eloquent\Model') in Router.php line 859
  4. at Router->substituteImplicitBindings(object(Route)) in Router.php line 844
  5. at Router->substituteBindings(object(Route)) in Router.php line 827
  6. at Router->findRoute(object(Request)) in Router.php line 691
  7. at Router->dispatchToRoute(object(Request)) in Router.php line 675
  8. at Router->dispatch(object(Request)) in Kernel.php line 246
  9. at Kernel->Illuminate\Foundation\Http{closure}(object(Request))
  10. at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
  11. at Pipeline->Illuminate\Routing{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
  12. at CheckForMaintenanceMode->handle(object(Request), object(Closure))
  13. at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
  14. at Pipeline->Illuminate\Pipeline{closure}(object(Request))
  15. at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
  16. at Pipeline->Illuminate\Routing{closure}(object(Request))
  17. at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
  18. at Pipeline->then(object(Closure)) in Kernel.php line 132
  19. at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
  20. at Kernel->handle(object(Request)) in index.php line 54

My route in /app/Http/routes.php

Route::group(['middleware' => ['auth']], function () {

    Route::get('trades', 'SteamInventory@getInventory');

});

My controller in /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";
    }
}
2

2 Answers

2
votes

Change this

SteamInventory

To this

SteamInventoryController

In this

Route::get('trades', 'SteamInventory@getInventory');
0
votes

Change your Route

   Route::get('trades', 'SteamInventory@getInventory');

TO

  Route::get('trades', 'SteamInventoryController@getInventory');