如何设置Composer.json文件以与Magento 2.4.6 p3一起使用

stszievb  于 12个月前  发布在  其他
关注(0)|答案(2)|浏览(156)

我们刚刚安装了一个新的Magento 2.4.6 p3 CE版本。
因此,我们确实想安装一些扩展,从这些模块开始:
composer require mageglaza/module-core
`在JsonFile.php行347:

“./composer.json”在第79行不包含有效的JSON解析错误:... s”:[{,“http-basic”:{

应为以下项之一:“STRING”,“}”“
我们在CLI中得到此错误
显然,我的composer.json文件有一个错误。下面是我们文件的详细信息。
请给我解释一下怎么修。谢谢!

{
    "name": "magento/project-community-edition",
    "description": "eCommerce Platform for Growth (Community Edition)",
    "type": "project",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "config": {
        "allow-plugins": {
            "dealerdirect/phpcodesniffer-composer-installer": true,
            "laminas/laminas-dependency-plugin": true,
            "magento/*": true,
            "php-http/discovery": true
        },
        "preferred-install": "dist",
        "sort-packages": true
    },
    "version": "2.4.6-p3",
    "require": {
        "magento/product-community-edition": "2.4.6-p3",
        "magento/composer-dependency-version-audit-plugin": "~0.1",
        "magento/composer-root-update-plugin": "~2.0"
    },
    "autoload": {
        "exclude-from-classmap": [
            "**/dev/**",
            "**/update/**",
            "**/Test/**"
        ],
        "files": [
            "app/etc/NonComposerComponentRegistration.php"
        ],
        "psr-0": {
            "": [
                "app/code/",
                "generated/code/"
            ]
        },
        "psr-4": {
            "Magento\\": "app/code/Magento/",
            "Magento\\Framework\\": "lib/internal/Magento/Framework/",
            "Magento\\Setup\\": "setup/src/Magento/Setup/"
        }
    },
    "require-dev": {
        "allure-framework/allure-phpunit": "^2",
        "dealerdirect/phpcodesniffer-composer-installer": "^0.7",
        "dg/bypass-finals": "^1.4",
        "friendsofphp/php-cs-fixer": "^3.8",
        "lusitanian/oauth": "^0.8",
        "magento/magento-coding-standard": "*",
        "magento/magento2-functional-testing-framework": "^4.3.1",
        "pdepend/pdepend": "^2.10",
        "phpmd/phpmd": "^2.12",
        "phpstan/phpstan": "^1.9",
        "phpunit/phpunit": "^9.5",
        "sebastian/comparator": "<=4.0.6",
        "sebastian/phpcpd": "^6.0",
        "symfony/finder": "^5.4",
        "symfony/process": "<=v5.4.23"
    },
    "conflict": {
        "gene/bluefoot": "*"
    },
    "autoload-dev": {
        "psr-4": {
            "Magento\\PhpStan\\": "dev/tests/static/framework/Magento/PhpStan/",
            "Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/",
            "Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
            "Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/",
            "Magento\\Tools\\": "dev/tools/Magento/Tools/",
            "Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/"
        }
    },
    "minimum-stability": "stable",
    "prefer-stable": true,
{   
    "repositories": [
{        
    ,"http-basic": {
        "repo.magento.com": {
            "username": "<your public key>",
            "password": "<your private key>"
        }
    }
}   
{       
        ,"mageplaza": {
            "repo.mageplaza.com": {
            "username": "<your mageplaza public key>",
            "password": "<your mageplaza private key>"
        }
    }
}
}
    ],
    "extra": {
        "magento-force": "override"
    }
}

字符串

ua4mk5z4

ua4mk5z41#

这是你的composer.json,你添加了不正确的倍数括号和逗号:

{
    "name": "magento/project-community-edition",
    "description": "eCommerce Platform for Growth (Community Edition)",
    "type": "project",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "config": {
        "allow-plugins": {
            "dealerdirect/phpcodesniffer-composer-installer": true,
            "laminas/laminas-dependency-plugin": true,
            "magento/*": true,
            "php-http/discovery": true
        },
        "preferred-install": "dist",
        "sort-packages": true
    },
    "version": "2.4.6-p3",
    "require": {
        "magento/product-community-edition": "2.4.6-p3",
        "magento/composer-dependency-version-audit-plugin": "~0.1",
        "magento/composer-root-update-plugin": "~2.0"
    },
    "autoload": {
        "exclude-from-classmap": [
            "**/dev/**",
            "**/update/**",
            "**/Test/**"
        ],
        "files": [
            "app/etc/NonComposerComponentRegistration.php"
        ],
        "psr-0": {
            "": [
                "app/code/",
                "generated/code/"
            ]
        },
        "psr-4": {
            "Magento\\": "app/code/Magento/",
            "Magento\\Framework\\": "lib/internal/Magento/Framework/",
            "Magento\\Setup\\": "setup/src/Magento/Setup/"
        }
    },
    "require-dev": {
        "allure-framework/allure-phpunit": "^2",
        "dealerdirect/phpcodesniffer-composer-installer": "^0.7",
        "dg/bypass-finals": "^1.4",
        "friendsofphp/php-cs-fixer": "^3.8",
        "lusitanian/oauth": "^0.8",
        "magento/magento-coding-standard": "*",
        "magento/magento2-functional-testing-framework": "^4.3.1",
        "pdepend/pdepend": "^2.10",
        "phpmd/phpmd": "^2.12",
        "phpstan/phpstan": "^1.9",
        "phpunit/phpunit": "^9.5",
        "sebastian/comparator": "<=4.0.6",
        "sebastian/phpcpd": "^6.0",
        "symfony/finder": "^5.4",
        "symfony/process": "<=v5.4.23"
    },
    "conflict": {
        "gene/bluefoot": "*"
    },
    "autoload-dev": {
        "psr-4": {
            "Magento\\PhpStan\\": "dev/tests/static/framework/Magento/PhpStan/",
            "Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/",
            "Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
            "Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/",
            "Magento\\Tools\\": "dev/tools/Magento/Tools/",
            "Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/"
        }
    },
    "minimum-stability": "stable",
    "prefer-stable": true,
    "repositories": {        
      "http-basic": {
          "repo.magento.com": {
              "username": "<your public key>",
              "password": "<your private key>"
          }
      },
      "mageplaza": {
          "repo.mageplaza.com": {
          "username": "<your mageplaza public key>",
          "password": "<your mageplaza private key>"
        }
      },
      "extra": {
          "magento-force": "override"
      }
    }
}

字符串

des4xlb0

des4xlb02#

看起来你的composer.json文件中有一些语法错误。具体来说,在“repositories”部分有额外的逗号和缺少的大括号。这里是你的composer.json文件的更正版本:

{
    "name": "magento/project-community-edition",
    "description": "eCommerce Platform for Growth (Community Edition)",
    "type": "project",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "config": {
        "allow-plugins": {
            "dealerdirect/phpcodesniffer-composer-installer": true,
            "laminas/laminas-dependency-plugin": true,
            "magento/*": true,
            "php-http/discovery": true
        },
        "preferred-install": "dist",
        "sort-packages": true
    },
    "version": "2.4.6-p3",
    "require": {
        "magento/product-community-edition": "2.4.6-p3",
        "magento/composer-dependency-version-audit-plugin": "~0.1",
        "magento/composer-root-update-plugin": "~2.0",
        "mageplaza/module-core": "*" // Add this line to require Mageplaza module-core
    },
    "autoload": {
        "exclude-from-classmap": [
            "**/dev/**",
            "**/update/**",
            "**/Test/**"
        ],
        "files": [
            "app/etc/NonComposerComponentRegistration.php"
        ],
        "psr-0": {
            "": [
                "app/code/",
                "generated/code/"
            ]
        },
        "psr-4": {
            "Magento\\": "app/code/Magento/",
            "Magento\\Framework\\": "lib/internal/Magento/Framework/",
            "Magento\\Setup\\": "setup/src/Magento/Setup/"
        }
    },
    "require-dev": {
        // ... (no changes here)
    },
    "conflict": {
        "gene/bluefoot": "*"
    },
    "autoload-dev": {
        // ... (no changes here)
    },
    "minimum-stability": "stable",
    "prefer-stable": true,
    "repositories": [
        {
            "type": "composer",
            "url": "https://repo.magento.com/"
        },
        {
            "type": "composer",
            "url": "https://repo.mageplaza.com/"
        }
    ],
    "extra": {
        "magento-force": "override"
    }
}

字符串
如果你想安装Mageplaza模块核心,请确保在“require”部分添加“mageplaza/module-core”:“*”。完成这些更改后,再次尝试运行composer require命令。

相关问题