Laravel - 调用未定义的方法 Illuminate\Foundation\Application::share()
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45979096/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel - Call to undefined method Illuminate\Foundation\Application::share()
提问by harunB10
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:
我正在从 Laravel 5.3 升级到 Laravel 5.4。问题是当我运行时composer update
,当涉及到php artisan optimize
部分时,我收到一个错误:
[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()
?
我在 StackOverflow 上阅读了几个问题,答案是用单例替换此共享方法。但是我在哪里可以找到这个share()
?
EDIT
编辑
My composer.json file:
我的 composer.json 文件:
"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"
}
}
采纳答案by AddWeb Solution Pvt Ltd
Project Share() method file is the Following Path:
项目 Share() 方法文件是以下路径:
Your Project >> Vendor >> laravel >> framework >> src >> Illuminate >> Container >> Container.php
您的项目 >> 供应商 >> laravel >> 框架 >> src >> Illuminate >> Container >> Container.php
Comment your share() method code and put below code.
注释您的 share() 方法代码并将其放在下面的代码中。
public function singleton($abstract, $concrete = null)
{
$this->bind($abstract, $concrete, true);
}