Composer在每个项目中使用内存不足,Mac OS X [英] Composer running out of memory on every project, Mac OS X

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

问题描述

我试图使用Composer在我的一个Laravel 4项目上安装 aws / aws-sdk-php ,我不能记得事件链,安装成功。从那以后,我一直收到Composer已经耗尽内存的错误 - 致命错误:在phar:/// usr / local / bin中允许536870912字节耗尽(尝试分配32字节)的内存大小/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 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)。安装完成成功,如果我增加 memory_limit 通过CLI当我运行 composer_update 但它需要永恒。

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运行内存不足?我有一个感觉,它仍然试图安装AWS SDK每次我运行作曲家更新。

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自更新更新它

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 耗时这么长,使用这么多内存是因为它必须跟踪每个库的版本,与您在<$ c $中定义的版本进行比较c> 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 =https://github.com/facebook/hhvm/wiki/Building-and-installing-HHVM-on-OSX-10.9 =nofollow>此处)加速了 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 安装最后使用的一组作曲家依赖项。

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.

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

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