Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 4.2 - ReflectionException (-1)

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)
    {
        //
    }

}
like image 319
Sasha Avatar asked Nov 28 '25 18:11

Sasha


1 Answers

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.

like image 177
ryanwinchester Avatar answered Dec 01 '25 06:12

ryanwinchester