dav*_*dev 2 php symfony composer-php
在我正在处理的 Symfony 2.7 项目中,我通过 Composer 1.6.5 使用了很多包。
几天后我无法再添加新包或重建 composer.lock。它不断耗尽内存。
当我尝试添加一个新包时,我开始注意到这个问题。但问题不在于那个包。因为作为测试,我现在试图通过删除该 composer.lock 文件并执行以下命令来重建我的 composer.lock:
php -d memory_limit=-1 C:/ProgramData/ComposerSetup/bin/composer.phar install -vvv
Run Code Online (Sandbox Code Playgroud)
当我在运行该命令时跟踪我的 ram 消耗时,它从未超过 1.5G 限制,而我的 Windows 机器仍然有足够的 ram 可用。
我注意到错误通常是在 Composer 尝试解析一个特定的包并将其写入缓存时/之后抛出的。那个特定的包确实消耗了大量内存(高达 0.5G) 一些研究告诉我这个包没有任何问题,它已经在我们的项目中,因此在 composer.json 中已经三年多了。我还在 Mac 上运行了相同的 composer install 命令,它确实设法解决了这个包并将其写入缓存,但是后来当它试图删除另一个不相关的包时它失败了,因为那时 mac 上的内存是完全消耗。
这是我得到的错误:
...
Downloading http://packagist.org/p/kriswallsmith/spork%24dafe3f5808d858c7b15bd464923710bf24d5f7457b7b6c50a298ca1bea1a35a0.json
Writing C:/Users/david/AppData/Local/Composer/repo/https---packagist.org/provider-kriswallsmith$spork.json into cache
Fatal error: Out of memory (allocated 1424228352) (tried to allocate 268435456 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/Solver.php on line 220
PHP Fatal error: Out of memory (allocated 1424228352) (tried to allocate 268435456 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/Solver.php on line 220
/cygdrive/c/ProgramData/ComposerSetup/bin/composer: line 10: 10284 Segmentation fault php "${dir}/composer.phar" "$@"
Run Code Online (Sandbox Code Playgroud)
奇怪的是,直到几天前,当一个使用过的作曲家需要我正在处理的包时,它工作得很好。
这是我的3个问题:
这是我的 composer.json 文件:
{
"name": "kulsol",
"license": "proprietary",
"type": "project",
"autoload": {
"psr-4": {
"": "src/",
"SymfonyStandard\\": "app/SymfonyStandard/"
},
"files": [
"src/helpers.php",
"app/AppKernel.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"require": {
"php": ">=5.3.9",
"symfony/symfony": "2.7.*",
"doctrine/orm": "2.5.*",
"doctrine/dbal": "<2.6",
"doctrine/doctrine-bundle": "~1.4",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "^2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~4.0",
"sensio/framework-extra-bundle": "~3.0,>=3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"jms/serializer-bundle": "~2.0.0",
"gedmo/doctrine-extensions": "2.4.3",
"symfony/stopwatch": "^2.7",
"vich/uploader-bundle": "^0.14.0",
"nesbot/carbon": "^1.21",
"swiftmailer/swiftmailer": "^5.4",
"mtdowling/cron-expression": "^1.0",
"cron/cron-bundle": "^1.0",
"mustache/mustache": "^2.9",
"leafo/lessphp": "<0.5",
"friendsofsymfony/elastica-bundle": "^3.1",
"guzzlehttp/guzzle": "^6.1",
"oro/doctrine-extensions": "^1.0",
"willdurand/geocoder-bundle": "^4.0",
"rlerdorf/opcache-status": "dev-master",
"henrikbjorn/stampie-bundle": "^1.0",
"stof/stampie-extra": "^0.2.0",
"isinlor/buzz-bundle": "^1.0",
"ocramius/proxy-manager": "~1.0",
"beberlei/DoctrineExtensions": "^1.0",
"doctrine/doctrine-migrations-bundle": "^1.0",
"ramsey/uuid": "3.*",
"phpoffice/phpexcel": "1.8.1",
"misd/guzzle-bundle": "v1.1.5",
"php-http/guzzle6-adapter": "^1.1",
"php-http/httplug-bundle": "^1.3",
"egeloen/google-map": "2.0.x-dev",
"egeloen/google-map-bundle": "dev-master#432438624d74f0384cc727b3609af3cc4314b152",
"ezyang/htmlpurifier": "^4.8",
"tfox/mpdf-port-bundle": "1.3.*",
"ramsey/uuid-doctrine": "^1.2",
"oneup/uploader-bundle": "^1.7",
"webmozart/assert": "^1.2",
"league/tactician-bundle": "~0.4",
"kuleuven-gbiomed/message": "^0.1.0",
"danielstjules/stringy": "^3.0",
"html2text/html2text": "^4.0",
"kuleuven-gbiomed/collection-utilities": "^0.1",
"kuleuven/distribution-api": "*",
"jms/serializer": "^1",
"friendsofsymfony/rest-bundle": "^2.3"
},
"require-dev": {
"sensio/generator-bundle": "~2.3",
"kahlan/kahlan": "^3.1",
"phpunit/phpunit": "^5.7",
"doctrine/doctrine-fixtures-bundle": "^2.3",
"friendsofphp/php-cs-fixer": "^2.2",
"liip/functional-test-bundle": "^1.7",
"vimeo/psalm": "^0.3.51",
"phpmd/phpmd": "^2.6"
},
"scripts": {
"post-root-package-install": [
"SymfonyStandard\\Composer::hookRootPackageInstall"
],
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
]
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"symfony-var-dir": "var",
"symfony-bin-dir": "bin",
"symfony-tests-dir": "tests"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/Isinlor/SensioBuzzBundle.git"
},
{
"type": "vcs",
"url": "https://github.com/kuleuven-gbiomed/collection-utilities.git"
},
{
"type": "path",
"url": "distribution/API/"
}
],
"config": {
"bin-dir": "bin"
}
}
Run Code Online (Sandbox Code Playgroud)
如果它可以帮助其他人,这是一个快速解决方案
事实证明,这是一个与 windows-xampp 相关的问题。xampp 仅支持 32 位版本的 php。这反过来意味着它始终只允许 memory_limit 为 1.5G(或 2G,其中 0.5G 分配给其他地方)。这有效地忽略了 php.ini 中的任何 memory_limit 设置或在运行时设置。
通过下载 64 位 php 并从该 64 位 php 版本运行 composer 解决了这个问题。这给了我高达 3G,足以运行作曲家