Laravel 4.2-ReflectionException(-1) [英] Laravel 4.2 - ReflectionException (-1)

查看:87
本文介绍了Laravel 4.2-ReflectionException(-1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到以下错误:

ReflectionException (-1)

Class PhotosController does not exist

这是我的路线:

Route::resource('photos', ' PhotosController');

当我更改为 Route :: get('photos','PhotosController @ index'); 时,它工作正常,但是使用 resource 时,它下降了吗?到底是怎么回事? 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)
    {
        //
    }

}

推荐答案

如果composer dump-autoload不能解决,则可能是类名或路由文件中的错字,或者在控制器上错误地使用了子目录/命名空间

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.

这篇关于Laravel 4.2-ReflectionException(-1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆