"unlimited memory" 中的作曲家 运行

Composer running out of "unlimited memory"

免责声明:我是 SHELL 菜鸟。

目标

安装 Drupal Address module.

尝试过

尝试 1composer require drupal/address

Returns:

Using version ^1.3 for drupal/address
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

Fatal error: Out of memory (allocated 435945472) (tried to allocate 2254277 bytes) in phar:///opt/cpanel/composer/bin/composer/src/Composer/Json/JsonFile.php on line 270

(预期为 php -r "echo ini_get('memory_limit').PHP_EOL;" returns 128M。)

尝试 2php -d memory_limit=-1 /opt/cpanel/composer/bin/composer require drupal/address

Returns:

Using version ^1.3 for drupal/address
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

Fatal error: Out of memory (allocated 435683328) (tried to allocate 1069411 bytes) in phar:///opt/cpanel/composer/bin/composer/src/Composer/Util/RemoteFilesystem.php on line 419

尝试 3php -d memory_limit=-1 composer.phar require drupal/address

Using version ^1.3 for drupal/address
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

Fatal error: Out of memory (allocated 435945472) (tried to allocate 1069279 bytes) in phar:///home/venturec/public_html/composer.phar/src/Composer/Util/RemoteFilesystem.php on line 419

备注

资源

composer diagnose:

Checking composer.json: OK
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: *Blur*
Dev Public Key Fingerprint: *Blur*
OK
Checking composer version: OK
Composer version: 1.6.3
PHP version: 5.6.34
PHP binary path: /opt/cpanel/ea-php56/root/usr/bin/php

composer.json

{
    "name": "drupal/drupal",
    "description": "Drupal is an open source content management platform powering millions of websites and applications.",
    "type": "project",
    "license": "GPL-2.0-or-later",
    "require": {
        "composer/installers": "^1.0.24",
        "wikimedia/composer-merge-plugin": "^1.4",
        "drupal/address": "^1.3"
    },
    "replace": {
        "drupal/core": "^8.4"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "config": {
        "preferred-install": "dist",
        "autoloader-suffix": "Drupal8"
    },
    "extra": {
        "_readme": [
            "By default Drupal loads the autoloader from ./vendor/autoload.php.",
            "To change the autoloader you can edit ./autoload.php.",
            "This file specifies the packages.drupal.org repository.",
            "You can read more about this composer repository at:",
            "https://www.drupal.org/node/2718229"
        ],
        "merge-plugin": {
            "include": [
                "core/composer.json"
            ],
            "recurse": false,
            "replace": false,
            "merge-extra": false
        },
        "installer-paths": {
            "core": ["type:drupal-core"],
            "modules/contrib/{$name}": ["type:drupal-module"],
            "profiles/contrib/{$name}": ["type:drupal-profile"],
            "themes/contrib/{$name}": ["type:drupal-theme"],
            "drush/contrib/{$name}": ["type:drupal-drush"],
            "modules/custom/{$name}": ["type:drupal-custom-module"],
            "themes/custom/{$name}": ["type:drupal-custom-theme"]
        }
    },
    "autoload": {
        "psr-4": {
            "Drupal\Core\Composer\": "core/lib/Drupal/Core/Composer"
        }
    },
    "scripts": {
        "pre-autoload-dump": "Drupal\Core\Composer\Composer::preAutoloadDump",
        "post-autoload-dump": [
          "Drupal\Core\Composer\Composer::ensureHtaccess"
        ],
        "post-package-install": "Drupal\Core\Composer\Composer::vendorTestCodeCleanup",
        "post-package-update": "Drupal\Core\Composer\Composer::vendorTestCodeCleanup"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    ]
}

您在共享主机中安装了 Drupal 运行,您的帐户下可分配的 CPU/memory 有限。将指令“memory_limit”设置为“-1”并不意味着您可以使用 "unlimited" 内存你的PHPscripts/commands,只代表你可以使用那台主机上你能分配的所有内存,也就是435+M(大概512M左右)。

如果您想继续使用该共享主机,您无能为力。 Drupal 需要足够的内存 运行,并且没有太多方法可以在共享主机上优化 Drupal。不过,您仍然可以尝试以下建议:

  1. 如果 PHP 7 在该主机上可用(您可以在 cPanel 中查看),请尝试 运行 Drupal 在 PHP 7 下。这允许 运行 Drupal 使用更少的内存。
  2. 无需使用 Composer 维护 Drupal,您可以手动下载模块,将其上传到主机,然后在 Drupal 管理面板中启用它。