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

后端 未结 5 1481
迷失自我
迷失自我 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:25

    This issue comes due to bindShared() method , just change it in to singleton()

    file is located here: /projectname/vendor/illuminate/html/HtmlServiceProvider.php

    change on line no : 36 and 49

    0 讨论(0)
  • 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 ()
        {
            // ... 
        });
    
    0 讨论(0)
  • 2021-02-19 01:36

    Okay based on your comment I see your issue (I should have noticed it sooner as you do mention the HTML component in your question.

    The illuminate/html component is no longer part of Laravel proper, and hasn't yet been updated to conform to 5.1 standards. In fact, I'm pretty sure it is now officially abandoned by Taylor.

    However, you can replace the illuminate/html requirement with laravelcollective/html - that's the official community takeover of illuminate/html and should be a drop-in replacement.

    No having to mess with stuff in vendor!

    0 讨论(0)
  • 2021-02-19 01:42

    Illuminate/html is abandoned. Use Collective/html instead.

    To install it use the following

    composer require "laravelcollective/html":"^5.2.0"
    

    Then in app/app.php file change/add as following
    for providers

    Collective\Html\HtmlServiceProvider::class
    

    and for aliases

    'Form' => Collective\Html\FormFacade::class,
    'Html' => Collective\Html\HtmlFacade::class,
    
    0 讨论(0)
  • 2021-02-19 01:46

    I am Rails developer & new to laravel & its just my first day and got stuck in this Form Builder issue. I have gone through many discussions and posts but got my solution on https://laravelcollective.com/docs/5.0/html To use blade form builder (Form::open) we need to change our composer.json and add "laravelcollective/html": "~5.0" in the require block. Then run composer update because then only new dependencies will be available to your project. Now add 'Collective\Html\HtmlServiceProvider', inside config/app.php inside providers block also you need to add

    'aliases' => [
        // ...
          'Form' => 'Collective\Html\FormFacade',
          'Html' => 'Collective\Html\HtmlFacade',
        // ...
      ],
    

    inside config/app.php in aliases block.

    run php artisan serve Enjoy Form builder with blade engine.

    0 讨论(0)
提交回复
热议问题