Laravel 4.2 - ReflectionException (-1)

蓝咒 提交于 2019-12-23 19:11:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!