在Laravel中不存在ReflectionException类App \ Http \ Controllers \ phonebookController

时间:2018-01-04 15:39:04

标签: php laravel exception laravel-5

我在localhost.the工作很好这个laravel项目。但是当我将它上传到实时服务器时,它会给出ReflectionException错误。实时地址

  

http://www.nayeemriddhi.net/laravelphone/phonebook   .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .........

PhonebookController.php

889143359540998144   make,sure,youre,ready,safely,view,solar,eclipse,aug,21,check,tip,eclipse,.

Web.php 文件代码

<?php

namespace App\Http\Controllers;


use App\Http\Requests\PhonebookRequest;
use App\Phonebook;
use Illuminate\Http\Request;

class PhonebookController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
            return view('phonebook');

    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }


     public function getData()
    {
        return Phonebook::orderBy('name','ASC')-> get();
    }


    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(PhonebookRequest $request)
    {
        $pb = new Phonebook;

        $pb -> name = $request -> name;

        $pb -> phone = $request -> phone;

        $pb -> email = $request -> email;

        $pb -> save();

        return $pb;

    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Phonebook  $phonebook
     * @return \Illuminate\Http\Response
     */
    public function show(Phonebook $phonebook)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Phonebook  $phonebook
     * @return \Illuminate\Http\Response
     */
    public function edit(Phonebook $phonebook)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Phonebook  $phonebook
     * @return \Illuminate\Http\Response
     */
    public function update(PhonebookRequest $request)
    {
        $pb = Phonebook::find($request->id);

        $pb -> name = $request -> name;

        $pb -> phone = $request -> phone;

        $pb -> email = $request -> email;

        $pb -> save();

    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Phonebook  $phonebook
     * @return \Illuminate\Http\Response
     */
    public function destroy(Phonebook $phonebook)
    {
        Phonebook::where('id', $phonebook->id )-> delete();
    }
}

2 个答案:

答案 0 :(得分:1)

变化:

Route::resource('phonebook', 'phonebookController');
Route::post('getData', 'phonebookController@getData');

要:

Route::post('getData', 'PhonebookController@getData');
Route::resource('phonebook', 'PhonebookController');

此外,运行php artisan route:clear以清除路由缓存。

答案 1 :(得分:0)

Route::resource('phonebook', 'PhonebookController');

Route::post('getData', 'PhonebookController@getData');

这是由于名称冲突。请注意路由文件中使用的控制器名称和名称。

可能是你在本地机器上使用了windows os而忽略了大写,但是在linux服务器上它会严格检查。