使用作曲家时,Symfony 4用完了内存



我正在使用Symfony 4 ...

我运行此命令:

php -d memory_limit=-1 composer.phar require form

脚本通过这些要点成功运行...

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Package symfony/lts is abandoned, you should avoid using it. Use     symfony/flex instead.
Generating autoload files
ocramius/package-versions:  Generating version class...
ocramius/package-versions: ...done generating version class
Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 255
!!  
!!   // Clearing the cache for the dev environment with debug                       
!!   // true   

然后我得到此错误:

!!  Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /Applications/XAMPP/xamppfiles/htdocs/xxxx/vendor/symfony/var-dumper/Cloner/Data.php on line 306

我可以在没有问题的情况下运行此脚本:

php -d memory_limit=-1 bin/console cache:clear

我不知道如何解决这个问题,因为我的命令说要绕过内存限制。我该怎么做才能超越此错误,此时我无法安装任何内容。

作曲家执行脚本时,是作曲家的单独的PHP调用,因此您的命令行指令不适用于它。

典型的解决方案是通过其配置文件配置PHP,以便所有实例都受到影响。

如果您无法访问更改PHP配置,则最佳选择可能是使用--no-scripts运行作曲家,然后尝试使用内存限制选项单独运行必要的脚本。

设置整个PHP过程的内存限制可能很危险,因为在Web上下文中执行PHP时,这可能会导致内存问题。因此,请确保仅更新CLI的配置。作曲家还通过环境变量COMPOSER_MEMORY_LIMIT提供配置点,您可以通过export COMPOSER_MEMORY_LIMIT=-1将其添加到您的.bashrc中,如果您始终要启用它,或者只需在安装过程中需要一次就需要一个命令本身即可:

COMPOSER_MEMORY_LIMIT=-1 composer require form

您也可以在作曲家的故障排除指南中找到所有不同的方法来解决与内存限制相关的问题。

最新更新