Call to undefined method Illuminate\Foundation\App

2020-07-03 03:57发布

I've just upgraded Laravel from 5.0 to 5.1.

I get this error:

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

So after some searching I need to change bindShared to a singleton.

I can do this in vendor/illuminate/html/HtmlServiceProvider.php

The issue is, what happens when another dev works on the project and performs a composer install, or I deploy to a server.

How can I persist changes to files in the vendor folder?

5条回答
▲ chillily
2楼-- · 2020-07-03 04:31

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,
查看更多
叼着烟拽天下
3楼-- · 2020-07-03 04:35

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 ()
    {
        // ... 
    });
查看更多
成全新的幸福
4楼-- · 2020-07-03 04:43

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!

查看更多
Ridiculous、
5楼-- · 2020-07-03 04:44

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

查看更多
Rolldiameter
6楼-- · 2020-07-03 04:49

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.

查看更多
登录 后发表回答