Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 805
panthro Avatar asked Jul 06 '15 15:07

panthro


5 Answers

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!

like image 184
alexrussell Avatar answered Nov 20 '22 14:11

alexrussell


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,
like image 45
Md. Shafiqur Rahman Avatar answered Nov 20 '22 14:11

Md. Shafiqur Rahman


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

like image 3
Jayant Pandey Avatar answered Nov 20 '22 15:11

Jayant Pandey


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 ()
    {
        // ... 
    });
like image 2
Igor Parra Avatar answered Nov 20 '22 15:11

Igor Parra


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.

like image 1
Amit Avatar answered Nov 20 '22 15:11

Amit