Laravel Upgrading To 5.2.0 From 5.1 error

2019-03-12 19:58发布

问题:

Getting the error on composer update command.

My composer.json file is:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.2.*",
        "illuminate/html": "^5.0",
        "barryvdh/laravel-debugbar": "~2.0",
        "spatie/laravel-paginateroute": "^2.0",
        "darkaonline/l5-swagger": "~2.0",
        "yajra/laravel-datatables-oracle": "~5.0",
        "phpoffice/phpexcel": "^1.8"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~4.0",
        "phpspec/phpspec": "~2.1",
        "symfony/dom-crawler": "~3.0",
        "symfony/css-selector": "~3.0"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "files": ["app/Helpers/helpers.php"],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "pre-update-cmd": [
            "php artisan clear-compiled"
        ],
        "post-update-cmd": [
            "php artisan optimize"
        ],
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

回答1:

You need to remove this outdated package (taken out of the core and no longer supported):

"illuminate/html": "^5.0",

When you remove it, you need to also remove its service providers / aliases. So, if you open up config/app.php, you will see a providers and aliases section. Remove these lines of code if you haven't done so already.

'Illuminate\Html\HtmlServiceProvider'

'Form'=> 'Illuminate\Html\FormFacade', 
'HTML'=> 'Illuminate\Html\HtmlFacade',

In place of it, you should install the Laravel collective package. To install that, replace the illuminate/html package with this:

"laravelcollective/html": "5.2.*"

Then in your config/app.php file, add this to your providers array:

Collective\Html\HtmlServiceProvider::class

and this to your aliases array:

'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,

The docs can be found here: https://laravelcollective.com/docs/5.2/html



回答2:

Look at this
https://laracasts.com/discuss/channels/laravel/call-to-undefined-method-illuminatefoundationapplicationbindshared

Quote "bindShared has been renamed to $app->singleton()"

[Edit] I think you have something is your own custom code what need to be changed from : $this->app->bindShared() to: $this->app->singleton().



回答3:

I solved it by the steps mentioned in Link1 Link2

After the upgrade please make sure all the Deprecations mentioned in Link2 are corrected in your current app. For me Illuminate\Contracts\Routing\Middleware had to be removed from all the Middlewares.

Also I had to install latest version of certain packages like "yajra/laravel-datatables-oracle": "~6.1.1",