Call to undefined method Illuminate\Foundation\Application::bindShared()

后端 未结 5 1480
迷失自我
迷失自我 2021-02-19 01:05

I\'ve just upgraded Laravel from 5.0 to 5.1.

I get this error:

Call to undefined method Illuminate\\Foundation\\Application::bindShared()
5条回答
  •  情书的邮戳
    2021-02-19 01:34

    The following Laravel features have been deprecated and will be removed entirely with the release of Laravel 5.2 in December 2015: ...

    The service container's bindShared method has been deprecated in favor of the singleton method. ...

    ref: https://laravel.com/docs/5.1/upgrade


    So, for example, starting from L5.1 you can safely change:

        $this->app->bindShared(UserObserver::class, function ()
        {
            // ... 
        });
    

    to:

        $this->app->singleton(UserObserver::class, function ()
        {
            // ... 
        });
    

提交回复
热议问题