Laravel 错误不起作用

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

Laravel errors not working

phplaravel

提问by mikelovelyuk

Whenever my code has an error.. All I get on the browser is a blank white page. No errors. Nothing.

每当我的代码有错误时.. 我在浏览器上得到的只是一个空白的白页。没有错误。没有。

I have tried turning debugto truein config/app.php. I have tried running php artisan optimize. No difference. I have tried this postand this is the resulting error in my command line;

我试图转向debugtrue在配置/ app.php。我试过跑步php artisan optimize。没有不同。我已经尝试过这篇文章,这是我的命令行中产生的错误;

The following exception is caused by a lack of memory and not having swap configured
Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details
PHP Fatal error:  Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:974
Stack trace:
#0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'proc_open(): fo...', 'phar:///usr/loc...', 974, Array)
#1 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(974): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
#2 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(784): Symfony\Component\Console\Application->getSttyColumns()
#3 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(745): Symfony\Component\Console\Application->getTerminalDimensions()
#4 phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php(675): Symfony\Component\Console\Application->getTerminalWidth()
#5 phar:///usr/local/bin/com in phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php on line 974

So here is another problem to deal with... and I still don't have errors showing. I just want to show some meaningful errors... what else can I try?

所以这是另一个需要处理的问题......我仍然没有显示错误。我只想显示一些有意义的错误……我还能尝试什么?

* UPDATE *

* 更新 *

I followed this guideas suggested in the error message above. I got a pretty positive looking response;

我按照上面错误消息中的建议遵循了本指南。我得到了非常积极的回应;

1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 1.6144 s, 665 MB/s

So I tried running composer updateagain. I got this response;

所以我composer update再次尝试跑步。我得到了这个回应;

Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Removing laravel/framework (v5.0.5)
  - Installing laravel/framework (v5.0.6)
    Downloading: 100%

  - Installing filp/whoops (1.1.3)
    Loading from cache

Writing lock file
Generating autoload files
Generating optimized class loader 
Compiling common classes
Compiling views

All good, right? But then, I still get a blank white page when loading my script with an error. Why??

一切都很好,对吧?但是,在加载我的脚本时出现错误,我仍然得到一个空白的白页。为什么??

采纳答案by Marcus Olsson

You get that error because Composer ran out of memory (it happens), how to fix this, see this for example: Composer update trouble

您收到该错误是因为 Composer 内存不足(它发生了),如何解决此问题,例如,请参见:Composer 更新问题

You could try to change the memory limit, or if you're developing locally and you get that error on your server; keeping the composer.lock-file in your git-repository (or where/whatever you use to deploy your project).

您可以尝试更改内存限制,或者如果您在本地开发并且在服务器上遇到该错误;将composer.lock-file保留在您的 git-repository(或用于部署项目的位置/任何地方)中。

Now, you are probably getting the white page because the framework actually isn't loaded (so the "debug" => trueisn't even read).

现在,您可能会看到白页,因为实际上没有加载框架(因此"debug" => true甚至没有读取)。

回答by chantez

first try this command
/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
/sbin/mkswap /var/swap.1
/sbin/swapon /var/swap.1
sudo composer update

首先试试这个命令
/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
/sbin/mkswap /var/swap.1
/sbin/swapon /var/swap.1
sudo composer更新

回答by Alex

It isn't a bug and fix it - To enable the swap you can use for example:

这不是错误并修复它 - 要启用交换,您可以使用例如:

/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
/sbin/mkswap /var/swap.1
/sbin/swapon /var/swap.1

Ref: https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors

参考:https: //getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors

Hope it will help you :)

希望它会帮助你:)

回答by Nick Mitchell

In the case you have cloned a laravel project and have attempted "composer update", you will first need to run "composer install" instead

如果您克隆了一个 Laravel 项目并尝试了“composer update”,您首先需要运行“composer install”

回答by Jr Relampagos

In my case, I have in my composer.json the predis/predis which is a package for REDIS. Since I wasn't able to install first REDIS, I think this is the main cause as to why I'm getting the error "The following exception is caused by a lack of memory and not having swap configured". I just removed the predis/predis on my composer.json and everything went fine.

就我而言,我的 composer.json 中有 predis/predis,它是 REDIS 的一个包。由于我无法先安装 REDIS,因此我认为这是导致出现错误“以下异常是由于内存不足且未配置交换导致”的主要原因。我刚刚删除了我的 composer.json 上的 predis/predis,一切都很好。

回答by Aris

This means that the composer does not have enough memory. This could be happening because the VPS runs out of memory and has no Swap space enabled. You can enable swap using below article: https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors

这意味着作曲家没有足够的内存。这可能是因为 VPS 内存不足并且没有启用交换空间。您可以使用以下文章启用交换:https: //getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors

However in my case I had enough memory and swap. A simple reboot fixed it. You can try reboot, especially if your server is ON for long time.

但是就我而言,我有足够的内存和交换。一个简单的重启修复了它。您可以尝试重新启动,特别是如果您的服务器长时间处于开启状态。