Laravel - Call to undefined method Illuminate\Foundation\Application::share()

空扰寡人 提交于 2021-01-27 10:18:19

问题


I am upgrading from Laravel 5.3 to Laravel 5.4. Problem is that when I run composer update and when it comes to php artisan optimize part, I get an error:

[Symfony\Component\Debug\Exception\FatalErrorException]
  Call to undefined method Illuminate\Foundation\Application::share()

I've read a couple of questions here on StackOverflow and the answer is to replace this share method with singleton. But where can I find this share()?

EDIT

My composer.json file:

    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.6.4",
        "laravel/framework": "5.4.*",
        "sngrl/sphinxsearch": "dev-master",
        "laravelcollective/html": "5.4.*",
        "aws/aws-sdk-php-laravel": "~3.0",
        "league/flysystem-aws-s3-v3": "^1.0",
        "mcamara/laravel-localization": "1.2.*",
        "league/csv": "^8.2",
        "mikehaertl/phpwkhtmltopdf": "^2.2",
        "barryvdh/laravel-snappy": "^0.3.3",
        "wemersonjanuario/wkhtmltopdf-windows": "dev-master",
        "nesbot/carbon": "^1.22",
        "uxweb/sweet-alert": "^1.4",
        "laracasts/flash": "^2.0",
        "guzzlehttp/guzzle": "^6.2",
        "illuminate/support": "5.4.*",
        "laravel/scout": "^3.0"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~5.7",
        "symfony/css-selector": "3.1.*",
        "symfony/dom-crawler": "3.1.*"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ],
        "post-install-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postInstall",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postUpdate",
            "php artisan optimize"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

回答1:


Project Share() method file is the Following Path:

Your Project >> Vendor >> laravel >> framework >> src >> Illuminate >> Container >> Container.php

Comment your share() method code and put below code.

public function singleton($abstract, $concrete = null)
{
   $this->bind($abstract, $concrete, true);
}


来源:https://stackoverflow.com/questions/45979096/laravel-call-to-undefined-method-illuminate-foundation-applicationshare

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!