I have a very simple routes.php file:
<?php
Route::get('/', 'TracksController@index');
And a simple TracksController.php file located at App\Http\Controllers:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Track as Track;
class TracksController extends Controller
{
function index(){
$tracks = Track::latest->get();
return view('tracks')->with(compact('tracks'));
}
}
But whenever I try to access that route I get this error:
ReflectionException in Route.php line 280:
Class App\Http\Controllers\TracksController does not exist
I have no idea what else I can do. I have:
- Run composer dumpautoload
- Run php artisan clear-compiled
- Checked permissions on the storage/* folders
- Forcing the namespace and/or fullpath of the TracksController in the routes file
But nothing seems to be working.
I even checked the vendor/composer/autoload_classmap.php file generated by composer and I cannot find the TracksController file there.
Any clues?
function index(){}
should bepublic
function index(){}` – Andrew Nolandd('test');
and remove theuse App\Track as Track;
and if you see the word test on your page then the answer is obvious – Achraf Khouadjacomposer dump-autoload
, with a hyphen. If it wasn't a typo, try that and see if that resolves the issue. – patricuscomposer dump-autoload
orcomposer dumpautoload
– Andrew Nolan