doutong4088 2019-03-04 08:40
浏览 1348

Laravel 5 - 错误调用未定义的方法Illuminate \ Events \ Dispatcher :: fire()

I'm working on a REST API using JWT.

The login route is good, but the router in group middleware jwt.auth doesn't work.

Error:

Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined method Illuminate\Events\Dispatcher::fire()

My code:

Route::group(['namespace' => 'Api'], function(){

    Route::get('user/login', 'AuthController@login');

    Route::group(['middleware' => ['jwt.auth']], function() {            
        Route::get('auth/me', 'AuthController@me');
    });
});
  • 写回答

6条回答 默认 最新

  • dtvpe4837413 2019-03-04 08:52
    关注

    Well, i solved this error. them of 2hours..... :/

    I modified the files Dispatcher.php of laravel.

    Solution:

    1) first in the file vendor\laravel\framework\src\Illuminate\Events\Dispatcher.php

    1.1)Add this code.

    /**
     * Fire an event and call the listeners.
     *
     * @param  string|object  $event
     * @param  mixed  $payload
     * @param  bool  $halt
     * @return array|null
     */
    public function fire($event, $payload = [], $halt = false);
    

    2) them in the second file. vendor\laravel\framework\src\Illuminate\Contracts\Events\Dispatcher.php

    2.1)Add this code.

    /**
     * Fire an event and call the listeners.
     *
     * @param  string|object  $event
     * @param  mixed  $payload
     * @param  bool  $halt
     * @return array|null
     */
    public function fire($event, $payload = [], $halt = false)
    {
        return $this->dispatch($event, $payload, $halt);
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?