【发布时间】:2016-04-09 04:48:20
【问题描述】:
在我的 Symfony 项目中,运行composer update/install 命令时出现一些错误:
这是我运行composer时出现的错误:
致命错误:允许的内存大小为 1073741824 字节已用尽(已尝试 分配 524288 字节)在 phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Util/RemoteFilesystem.php 在第 189 行
如您所见,我以管理员身份运行提示命令,但即使我以非管理员身份运行命令,也会发生同样的错误。
我还检查了页面 here 以设置他们建议我运行 composer 的更改而不会遇到麻烦。
我在 Windows 10 上并为我的项目使用 wamp 服务器。
所以在我的 php.ini 中我写了这一行:memory_limit = 2G
为了确定,我重新启动了 wamp 等我的电脑。当我运行命令php -r "echo ini_get('memory_limit').PHP_EOL;" 时,它总是显示128M。
如果我运行composer diagnose 命令,这就是我从提示命令得到的结果:
正如您在此处看到的,composer 在我的 composer.json 上显示一个错误。
这是我的composer.json 文件:
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-4": { "": "src/" }
},
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=5.3.9",
"symfony/symfony": "2.7.*",
"doctrine/orm": "^2.4.8",
"doctrine/doctrine-bundle": "~1.4",
"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.2",
"incenteev/composer-parameter-handler": "~2.0",
"friendsofsymfony/user-bundle": "~2.0",
"knplabs/doctrine-behaviors": "~1.1",
"friendsofsymfony/jsrouting-bundle": "^1.5",
"jms/serializer-bundle": "^1.1",
"sonata-project/seo-bundle": "^2.0",
"genemu/form-bundle": "2.2.*",
"elao/web-profiler-extra-bundle" : "~2.3@dev",
"maxmind/geoip": "dev-master",
"a2lix/translation-form-bundle": "^2.0",
"ircmaxell/password-compat": "^1.0",
"sonata-project/translation-bundle": "^1.0",
"sp/bower-bundle": "^0.11.0",
"ensepar/html2pdf-bundle" : "~2.0"
},
"require-dev": {
"sensio/generator-bundle": "~2.3",
"doctrine/doctrine-fixtures-bundle": "^2.3"
},
"scripts": {
"pre-install-cmd": [
"BetonDirect\\EntityBundle\\HerokuDatabase::populateEnvironment"
],
"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::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::prepareDeploymentTarget"
]
},
"config": {
"bin-dir": "bin"
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "hard-copy",
"incenteev-parameters": {
"file": "app/config/parameters.yml",
"env-map": {
"database_driver": "DATABASE_DRIVER",
"database_host": "DATABASE_HOST",
"database_port": "DATABASE_PORT",
"database_name": "DATABASE_NAME",
"database_user": "DATABASE_USER",
"database_password": "DATABASE_PASSWORD"
}
},
"branch-alias": {
"dev-master": "2.7-dev"
}
}
}
我也在我的 wamp 中禁用了服务器 xdebug zend 扩展,但它也不起作用(当我更改 memory_limit 时出现同样的问题,没有任何变化)。
如果您有一些问题,我很感激。
【问题讨论】:
-
您真的需要将
minimum-stabilitiy选项设置为dev吗?这样做需要 Composer 的依赖解析器考虑更多版本,这会大大增加内存使用量。 -
您确定为 PHP CLI 更改了 php.ini 吗?通常有两种独立的配置,一种用于 Web 服务器,一种用于 CLI。
-
@JimL 我已经在 wamp 的两个 php.ini 中将
memory_limit更改为 2G,例如在C:\wamp\bin\php\php5.5.12和C:\wamp\bin\apache\apache2.4.9\bin中。您认为没有正确的文件? -
也许,运行
php --ini以确保 -
如果只有一些软件包您想要(或必须)使用它们的开发版本,您仍然可以在这些软件包的版本号后缀
@dev(或任何其他稳定性标志) .这将迫使 Composer 只考虑这些包的开发版本,而对其他所有包使用稳定版本。
标签: php json symfony composer-php