首页 > 解决方案 > Symfony 3.3.18:作曲家更新/安装/需要火 => 内存不足

问题描述

我正在尝试从 Symfony 3.3 升级项目。我在运行 composer update 时遇到此错误,在删除 composer.lock 和 composer require 后运行 composer install。

PHP 致命错误: phar://C:/Users/bbarhoum/Documents/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/Solver.php 中的内存不足(已分配 1601437696)(试图分配 268435456 字节)第 223 行

这是我的composer.json:

{
    "name" : "symfony/framework-standard-edition",
    "license" : "MIT",
    "type" : "project",
    "description" : "The \"Symfony Standard Edition\" distribution",
    "autoload" : {
        "psr-0" : {
            "Detection" : "vendor/mobile-detect/namespaced"
        },
        "psr-4" : {
            "" : "src/"
        },
        "classmap" : [
            "app/AppKernel.php",
            "app/AppCache.php"
        ],
        "files" : [
            "vendor/wsdlwriter/classes/WsdlDefinition.php",
            "vendor/wsdlwriter/classes/WsdlWriter.php",
            "vendor/php-ga/src/autoload.php",
            "vendor/phpunit-selenium/PHPUnit/Extensions/SeleniumTestCase/Autoload.php",
            "vendor/htmlpurifier/library/HTMLPurifier.auto.php"
        ]
    },
    "require" : {
        "php" : ">=5.5.9",
        "symfony/symfony" : "3.3.*",
        "doctrine/orm" : "^2.5",
        "doctrine/doctrine-bundle" : "^1.6",
        "doctrine/doctrine-cache-bundle" : "^1.2",
        "symfony/swiftmailer-bundle" : "^2.3",
        "symfony/assetic-bundle" : "^2.3",
        "symfony/monolog-bundle" : "^3.0",
        "symfony/polyfill-apcu" : "^1.0",
        "sensio/distribution-bundle" : "^5.0",
        "sensio/framework-extra-bundle" : "^3.0.2",
        "incenteev/composer-parameter-handler" : "^2.0",
        "elasticsearch/elasticsearch" : "~5.0",
        "white-october/pagerfanta-bundle": "^1.2",
        "jasig/phpcas" : "1.3.5"
    },
    "require-dev" : {
        "sensio/generator-bundle" : "^3.0",
        "symfony/phpunit-bridge" : "^3.0",
        "doctrine/doctrine-fixtures-bundle" : "2.3.0",
        "phpunit/phpunit" : "5.5.*"
    },
    "scripts" : {
        "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"
        ]
    },
    "config" : {
        "bin-dir" : "bin",
        "platform" : {
            "php" : "5.6.28"
        }
    },
    "minimum-stability" : "stable",
    "extra" : {
        "symfony-app-dir" : "app",
        "symfony-bin-dir" : "bin",
        "symfony-web-dir" : "web",
        "symfony-assets-install" : "relative",
        "incenteev-parameters" : {
            "file" : "app/config/parameters.yml"
        },
        "branch-alias" : {
            "dev-master" : "3.2-dev"
        }
    }
}

作曲家诊断:

Checking platform settings: OK 
Checking git settings: OK 
Checking http connectivity to packagist: OK 
Checking https connectivity to packagist: OK 
Checking HTTP proxy: OK 
Checking HTTP proxy support for request_fulluri: OK 
Checking HTTPS proxy support for request_fulluri: OK 
Checking github.com rate limit: OK 
Checking disk free space: OK 
Checking pubkeys: Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642 Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952 OK Checking composer version: OK 
Composer version:1.9.3 
PHP version: 5.6.28 - Package overridden via config.platform (actual: 5.6.30)

标签: phpsymfonycomposer-phpout-of-memorysymfony-3.3

解决方案


尝试运行删除 PHP 内存限制的命令。

php -d memory_limit=-1 composer update

您可能需要使用 composer exe 的绝对路径。

如果这不起作用,请检查您的 PHP 版本是用于 x86 还是 x64,如果可能,请更改为 x64 版本。

还要确保您已将作曲家更新到最新版本,因为它会提高性能。composer self-update

希望这对我有很多帮助。


推荐阅读