/bootstrap/start.php 中的 Laravel 错误:\Illuminate\Foundation\Application not found

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21053231/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 08:51:54  来源:igfitidea点击:

Laravel error in /bootstrap/start.php: \Illuminate\Foundation\Application not found

phplaravel

提问by Chris vCB

So, I installed Laravel on a dev server (php5.5.3, standard installation, mcrypt installed), and I get the following error message:

所以,我在开发服务器上安装了 Laravel(php5.5.3,标准安装,mcrypt 安装),我收到以下错误消息:

Fatal error: Class 'Illuminate\Foundation\Application' not found in /[path_to_laravel_app]/bootstrap/start.php on line 14

Quite odd, and I haven't seen a solution to this file, although I've seen plenty of similar errors. Any advice welcome. Thanks!

很奇怪,我还没有看到这个文件的解决方案,尽管我看到了很多类似的错误。欢迎任何建议。谢谢!

回答by Sam

/bootstrap/start.phpis created after composer installby running Laravel's php artisan optimize. I've had a lot of issues on this during upgrades of Laravel, but removing /bootstrap/start.php, composer.lock, and the vendordirectory and re-running composer installshould fix this issue.

/bootstrap/start.phpcomposer install通过运行 Laravel 的php artisan optimize. 我Laravel的升级过程中有很多关于这个问题,但删除/bootstrap/start.phpcomposer.lockvendor目录,并重新运行composer install应该可以解决这个问题。

回答by Jnanaranjan

Run this command:

运行此命令:

composer update --no-scripts

In my case I have added another required package(Guzzle) in the compser.json file separately(in the last line but it should be after the laravel package line) and updated the compsoser and came across this issue.

在我的情况下,我在 compser.json 文件中单独添加了另一个必需的包(Guzzle)(在最后一行,但它应该在 laravel 包行之后)并更新了 compsoser 并遇到了这个问题。

I have checked and my vendor/laravel folder has gone. That was preventing me to run any artisian command.

我已经检查过了,我的 vendor/laravel 文件夹不见了。这阻止了我运行任何工匠命令。

So "--no-scripts" worked for me as it prevents any scripts to be included before executing artisan.

所以“--no-scripts”对我有用,因为它可以防止在执行 artisan 之前包含任何脚本。

You can use another method in case you are having issues.

如果遇到问题,您可以使用另一种方法。

  1. Install another raw laravel and copy all the files from the vendor file to your old repostory.
  2. Change permission of storage and bootstrap folder to 775 or 777.
  3. Delete everything in the session and view folder of storage/framework
  1. 安装另一个原始 laravel 并将所有文件从供应商文件复制到旧的存储库。
  2. 将存储和引导文件夹的权限更改为 775 或 777。
  3. 删除会话中的所有内容并查看存储/框架的文件夹

回答by Al-Punk

Correct the composer.json. This might happen after you have added a new package configuration by dublicating the require tag.

更正 composer.json。在通过复制 require 标记添加新的包配置后,可能会发生这种情况。

Do not create yet another

不要创建另一个

require: {
     ..
    }

use the previous defined one.

使用之前定义的。

Then follow the accepted answer to re-install the packages.

然后按照接受的答案重新安装软件包。

回答by Majbah Habib

Just Run the command

只需运行命令

composer install --no-scripts

Or,

或者,

composer update --no-scripts

回答by Sampath Perera

Double check your composer.json file. If you have error on "require": section this error will occur.

仔细检查您的 composer.json 文件。如果您在“require”:部分有错误,则会发生此错误。

Just restore a previous version of composer.json file and run composer update.

只需恢复之前版本的 composer.json 文件并运行 composer update。