问题
I am getting following error:
ReflectionException (-1)
Class PhotosController does not exist
This is my route:
Route::resource('photos', ' PhotosController');
When I change to Route::get('photos', 'PhotosController@index'); it is working fine, but using resource it is falling? What is going on? PhotosController:
<?php
class PhotosController extends \BaseController {
/**
* Display a listing of the resource.
* GET /photos
*
* @return Response
*/
public function index()
{
return Photo::all();
}
/**
* Show the form for creating a new resource.
* GET /photos/create
*
* @return Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
* POST /photos
*
* @return Response
*/
public function store()
{
//
}
/**
* Display the specified resource.
* GET /photos/{id}
*
* @param int $id
* @return Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
* GET /photos/{id}/edit
*
* @param int $id
* @return Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
* PUT /photos/{id}
*
* @param int $id
* @return Response
*/
public function update($id)
{
//
}
/**
* Remove the specified resource from storage.
* DELETE /photos/{id}
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
}
}
回答1:
If composer dump-autoload
doesn't fix it, then it is probably a typo in the class name or routes file, or incorrectly using subdirectories/namespaces on your controllers.
来源:https://stackoverflow.com/questions/25428645/laravel-4-2-reflectionexception-1