作曲家在每个项目上都内存不足,Mac OS X [英] Composer running out of memory on every project, Mac OS X

查看:15
本文介绍了作曲家在每个项目上都内存不足,Mac OS X的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我昨天尝试使用 Composer 在我的 Laravel 4 项目之一上安装 aws/aws-sdk-php,我不记得确切的事件链,但它没有成功安装.从那以后,我一直收到 Composer 内存不足的错误 - 致命错误:在 phar:///usr/local/bin/composer/中允许的内存大小为 536870912 字节已用尽(尝试分配 32 字节)src/Composer/DependencyResolver/RuleWatchGraph.php 第 52 行.

I attempted to install aws/aws-sdk-php yesterday on one of my Laravel 4 projects using Composer, I cannot remember exactly the chain of events but it did not install successfully. Ever since, I have been receiving errors that Composer has run out of memory - Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 32 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52.

我将 php.ini memory_limit 增加到 -1,这仍然发生在我的开发和生产环境中(生产环境是 Cent OS 6).如果我在运行 composer_update 时通过 CLI 增加 memory_limit 则安装成功完成,但这需要很长时间.

I increased the php.ini memory_limit to -1 and this still occurs, both in my development and production environments (production is Cent OS 6). Installation completes successfully if I increase the memory_limit via the CLI when I run composer_update but it takes an eternity.

是否需要清除某种缓存以防止 Composer 内存不足?我感觉每次运行 composer update 时它仍在尝试安装 AWS 开发工具包.

Is there some sort of cache that I need to clear to prevent Composer for running out of memory? I have a feeling that it is still trying to install the AWS SDK every time I run composer update.

作曲家文件

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "require": {
        "laravel/framework": "4.0.*",
        "rtablada/package-installer": "dev-master",
        "mogreet/mogreet-php": "dev-master",
        "twilio/laratwilio": "dev-master",
        "balloon/elephant.io": "dev-master",
        "facebook/php-sdk": "dev-master",
        "way/generators": "dev-master",
        "codesleeve/asset-pipeline": "dev-master",
        "natxet/CssMin": "dev-master"
    },
    "autoload": {
        "classmap": [
            "app/commands",
            "app/controllers",
            "app/models",
            "app/database/migrations",
            "app/database/seeds",
            "app/tests/TestCase.php",
            "app/libraries"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan optimize"
        ],
        "pre-update-cmd": [
            "php artisan clear-compiled"
        ],
        "post-update-cmd": [
            "php artisan optimize"
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    },
    "minimum-stability": "dev"
}

推荐答案

在继续之前,请始终确保您运行的是最新版本的composer,您可以通过composer self-update进行更新代码>

Before going any further always make sure you're running the latest version of composer, you can update it via composer self-update

当您运行 composer update 时,它会为您的每个库(或最新版本)计算最新的 gitref,然后安装该版本的库.然后它将这些版本存储在 composer.lock 文件中.

When you run composer update it will calculate the most up-to-date gitref for each of your libraries (or the latest release) and then will install that version of the library. It will then store these versions in the composer.lock file.

当您运行 composer install 时,它只会安装 composer.lock 文件中定义的版本.

When you run composer install, it simply installs the versions defined in the composer.lock file.

composer update 需要这么长时间并使用这么多内存的原因是因为它必须跟踪每个库的版本,将其与您在 composer.json 中定义的版本进行比较 然后检查该库的所有依赖项.这是一个相当密集的过程.

The reason composer update takes so long and uses so much memory is because it has to trace every library's version, compare it with the version you have defined in your composer.json and then check all of that library's dependencies. This is quite an intensive process.

我发现使用 hhvm 运行 composer(你可以安装它 here) 大大加快了 composer update 进程.

I find that running composer using hhvm (you can install it here) speeds up the composer update process massively.

除此之外,您只需要忍受高内存使用并在 php.ini 文件中增加它.确保更新与 CLI 相关的那个.

Short of that, you just have to live with the high memory usage and increase it in your php.ini file. Make sure you update the one that is relevant for your CLI.

您不应该在生产环境中运行 composer update.您应该只在开发时更新您的依赖项,然后在生产环境中使用 composer install 安装您最后使用的一组 composer 依赖项.

You should never run composer update in the production environment. You should only update your dependencies when you're developing, and then use composer install to install your last used set of composer dependencies when you're in a production environment.

这篇关于作曲家在每个项目上都内存不足,Mac OS X的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆