如何使用composer安装Magento2样本模块?

时间:2015-11-08 12:13:03

标签: php magento composer-php magento2

我在本地机器上使用Magento 2 EE。我一直在寻找这个问题几个小时。我想安装此处列出的示例页面模块:

https://github.com/magento/magento2-samples/tree/master/sample-module-newpage

我没有上传并尝试通过创建和上传文件和文件夹来对所有内容进行操作,而是在页面上阅读此引用:

This module is intended to be installed using composer.

我是Composer的新手,Grunt和Github的世界以这种方式分叉和更新文件;我老了但是想要适应。

我该怎么做?我已经设法在我的机器上安装Composer,并且我将终端打开到Magento 2的文件夹。我可以运行github命令或Composer命令;我试过了:

#localhost:magento2ee: composer magento/sample-module-newpage

  [InvalidArgumentException]                               
  Command "magento/sample-module-newpage" is not defined.  

我也试过

#localhost:magento2ee: composer require magento/sample-module-newpage



  [InvalidArgumentException]
Could not find package magento/sample-module-newpage at any version for your minimum-stability (alpha). Check the package spelling or your minimum-stability  

以下是我的composer.json文件

{
    "name": "magento/magento2ee",
    "description": "Magento 2 (Enterprise Edition)",
    "type": "magento-core",
    "version": "1.0.0-beta4",
    "license": [
        "proprietary"
    ],
    "require": {
        "php": "~5.5.0|~5.6.0",
        "zendframework/zend-stdlib": "2.4.0",
        "zendframework/zend-code": "2.4.0",
        "zendframework/zend-server": "2.4.0",
        "zendframework/zend-soap": "2.4.0",
        "zendframework/zend-uri": "2.4.0",
        "zendframework/zend-validator": "2.4.0",
        "zendframework/zend-console": "2.4.0",
        "zendframework/zend-modulemanager": "2.4.0",
        "zendframework/zend-mvc": "2.4.0",
        "zendframework/zend-text": "2.4.0",
        "zendframework/zend-i18n": "2.4.0",
        "zendframework/zend-eventmanager": "2.4.0",
        "zendframework/zend-view": "2.4.0",
        "zendframework/zend-servicemanager": "2.4.0",
        "zendframework/zend-json": "2.4.0",
        "zendframework/zend-config": "2.4.0",
        "zendframework/zend-form": "2.4.0",
        "zendframework/zend-di": "2.4.0",
        "zendframework/zend-serializer": "2.4.0",
        "zendframework/zend-log": "2.4.0",
        "zendframework/zend-http": "2.4.0",
        "magento/zendframework1": "1.12.13",
        "composer/composer": "1.0.0-alpha10",
        "monolog/monolog": "1.11.0",
        "oyejorge/less.php": "1.7.0.3",
        "pelago/emogrifier": "0.1.1",
        "tubalmartin/cssmin": "2.4.8-p4",
        "solarium/solarium": "3.3.0",
        "magento/magento-composer-installer": "*",
        "braintree/braintree_php" : "2.39.0",
        "symfony/console": "~2.3 <2.7"
    },
    "require-dev": {
        "lib-libxml": "*",
        "ext-ctype": "*",
        "ext-gd": "*",
        "ext-spl": "*",
        "ext-dom": "*",
        "ext-simplexml": "*",
        "ext-mcrypt": "*",
        "ext-hash": "*",
        "ext-curl": "*",
        "ext-iconv": "*",
        "ext-intl": "*",
        "ext-xsl": "*",
        "ext-mbstring": "*",
        "phpunit/phpunit": "4.1.0",
        "squizlabs/php_codesniffer": "1.5.3",
        "phpmd/phpmd": "@stable",
        "pdepend/pdepend": "2.0.6",
        "sjparkinson/static-review": "~4.1",
        "fabpot/php-cs-fixer": "~1.2",
        "lusitanian/oauth": "~0.3"
    },
    "replace": {
        "magento/module-admin-notification": "self.version",
        "magento/module-advanced-pricing-import-export": "self.version",
        "magento/module-authorization": "self.version",
        "magento/module-authorizenet": "self.version",
        "magento/module-backend": "self.version",
        "magento/module-backup": "self.version",
        "magento/module-braintree": "self.version",
        "magento/module-worldpay": "self.version",
        "magento/module-bundle": "self.version",
        "magento/module-bundle-import-export": "self.version",
        "magento/module-cache-invalidate": "self.version",
        "magento/module-captcha": "self.version",
        "magento/module-catalog": "self.version",
        "magento/module-catalog-import-export": "self.version",
        "magento/module-catalog-inventory": "self.version",
        "magento/module-catalog-rule": "self.version",
        "magento/module-catalog-search": "self.version",
        "magento/module-catalog-url-rewrite": "self.version",
        "magento/module-catalog-widget": "self.version",
        "magento/module-checkout": "self.version",
        "magento/module-checkout-agreements": "self.version",
        "magento/module-cms": "self.version",
        "magento/module-cms-url-rewrite": "self.version",
        "magento/module-config": "self.version",
        "magento/module-configurable-import-export": "self.version",
        "magento/module-configurable-product": "self.version",
        "magento/module-contact": "self.version",
        "magento/module-cookie": "self.version",
        "magento/module-cron": "self.version",
        "magento/module-currency-symbol": "self.version",
        "magento/module-customer": "self.version",
        "magento/module-customer-import-export": "self.version",
        "magento/module-deploy": "self.version",
        "magento/module-design-editor": "self.version",
        "magento/module-developer": "self.version",
        "magento/module-dhl": "self.version",
        "magento/module-directory": "self.version",
        "magento/module-downloadable": "self.version",
        "magento/module-eav": "self.version",
        "magento/module-email": "self.version",
        "magento/module-advanced-search": "self.version",
        "magento/module-fedex": "self.version",
        "magento/module-gift-message": "self.version",
        "magento/module-google-adwords": "self.version",
        "magento/module-google-analytics": "self.version",
        "magento/module-google-optimizer": "self.version",
        "magento/module-google-shopping": "self.version",
        "magento/module-google-tag-manager": "self.version",
        "magento/module-grouped-import-export": "self.version",
        "magento/module-grouped-product": "self.version",
        "magento/module-import-export": "self.version",
        "magento/module-indexer": "self.version",
        "magento/module-integration": "self.version",
        "magento/module-layered-navigation": "self.version",
        "magento/module-log": "self.version",
        "magento/module-msrp": "self.version",
        "magento/module-media-storage": "self.version",
        "magento/module-multishipping": "self.version",
        "magento/module-newsletter": "self.version",
        "magento/module-offline-payments": "self.version",
        "magento/module-offline-shipping": "self.version",
        "magento/module-page-cache": "self.version",
        "magento/module-payment": "self.version",
        "magento/module-paypal": "self.version",
        "magento/module-persistent": "self.version",
        "magento/module-product-alert": "self.version",
        "magento/module-quote": "self.version",
        "magento/module-reports": "self.version",
        "magento/module-require-js": "self.version",
        "magento/module-review": "self.version",
        "magento/module-rss": "self.version",
        "magento/module-rule": "self.version",
        "magento/module-sales": "self.version",
        "magento/module-sales-rule": "self.version",
        "magento/module-sales-sequence": "self.version",
        "magento/module-search": "self.version",
        "magento/module-send-friend": "self.version",
        "magento/module-shipping": "self.version",
        "magento/module-sitemap": "self.version",
        "magento/module-solr": "self.version",
        "magento/module-store": "self.version",
        "magento/module-swatches": "self.version",
        "magento/module-tax": "self.version",
        "magento/module-tax-import-export": "self.version",
        "magento/module-theme": "self.version",
        "magento/module-translation": "self.version",
        "magento/module-ui": "self.version",
        "magento/module-ups": "self.version",
        "magento/module-url-rewrite": "self.version",
        "magento/module-user": "self.version",
        "magento/module-usps": "self.version",
        "magento/module-version": "self.version",
        "magento/module-webapi": "self.version",
        "magento/module-weee": "self.version",
        "magento/module-widget": "self.version",
        "magento/module-wishlist": "self.version",
        "magento/module-admin-gws": "self.version",
        "magento/module-advanced-checkout": "self.version",
        "magento/module-banner": "self.version",
        "magento/module-banner-customer-segment": "self.version",
        "magento/module-catalog-event": "self.version",
        "magento/module-catalog-permissions": "self.version",
        "magento/module-custom-attribute-management": "self.version",
        "magento/module-customer-balance": "self.version",
        "magento/module-customer-custom-attributes": "self.version",
        "magento/module-customer-finance": "self.version",
        "magento/module-customer-segment": "self.version",
        "magento/module-enterprise": "self.version",
        "magento/module-gift-card": "self.version",
        "magento/module-gift-card-account": "self.version",
        "magento/module-gift-registry": "self.version",
        "magento/module-gift-wrapping": "self.version",
        "magento/module-invitation": "self.version",
        "magento/module-logging": "self.version",
        "magento/module-multiple-wishlist": "self.version",
        "magento/module-ogone": "self.version",
        "magento/module-cybersource": "self.version",
        "magento/module-pci": "self.version",
        "magento/module-persistent-history": "self.version",
        "magento/module-price-permissions": "self.version",
        "magento/module-promotion-permissions": "self.version",
        "magento/module-reminder": "self.version",
        "magento/module-reward": "self.version",
        "magento/module-rma": "self.version",
        "magento/module-sales-archive": "self.version",
        "magento/module-advanced-catalog": "self.version",
        "magento/module-scalable-checkout": "self.version",
        "magento/module-scalable-oms": "self.version",
        "magento/module-scheduled-import-export": "self.version",
        "magento/module-target-rule": "self.version",
        "magento/module-variable": "self.version",
        "magento/module-versions-cms": "self.version",
        "magento/module-website-restriction": "self.version",
        "magento/theme-adminhtml-backend": "self.version",
        "magento/theme-frontend-blank": "self.version",
        "magento/theme-frontend-luma": "self.version",
        "magento/language-de_de": "self.version",
        "magento/language-en_us": "self.version",
        "magento/language-es_es": "self.version",
        "magento/language-fr_fr": "self.version",
        "magento/language-nl_nl": "self.version",
        "magento/language-pt_br": "self.version",
        "magento/language-zh_cn": "self.version",
        "magento/framework": "self.version",
        "trentrichardson/jquery-timepicker-addon": "1.4.3",
        "colinmollenhour/cache-backend-redis": "dev-master#193d377b7fb2e88595578b282fa01a62d1185abc",
        "colinmollenhour/credis": "dev-master#f07bbfd4117294f462f0fb19c49221d350bf396f",
        "linkorb/jsmin-php": "1.1.2",
        "phpseclib/phpseclib": "0.2.1",
        "components/jquery": "1.11.0",
        "blueimp/jquery-file-upload": "5.6.14",
        "components/jqueryui": "1.10.4",
        "twbs/bootstrap": "3.1.0",
        "tinymce/tinymce": "3.4.7"
    },
    "extra": {
        "component_paths": {
            "trentrichardson/jquery-timepicker-addon": "lib/web/jquery/jquery-ui-timepicker-addon.js",
            "colinmollenhour/cache-backend-redis": "lib/internal/Cm/Cache/Backend/Redis.php",
            "colinmollenhour/credis": "lib/internal/Credis",
            "linkorb/jsmin-php": "lib/internal/JSMin",
            "phpseclib/phpseclib": "lib/internal/phpseclib",
            "components/jquery": [
                "lib/web/jquery.js",
                "lib/web/jquery/jquery.min.js",
                "lib/web/jquery/jquery-migrate.js",
                "lib/web/jquery/jquery-migrate.min.js"
            ],
            "blueimp/jquery-file-upload": "lib/web/jquery/fileUploader",
            "components/jqueryui": [
                "lib/web/jquery/jquery-ui.js",
                "lib/web/jquery/jquery-ui.min.js"
            ],
            "twbs/bootstrap": [
                "lib/web/jquery/jquery.tabs.js"
            ],
            "tinymce/tinymce": "lib/web/tiny_mce"
        }
    },
    "config": {
        "use-include-path": true
    },
    "autoload": {
        "psr-4": {
            "Magento\\Framework\\": "lib/internal/Magento/Framework/",
            "Magento\\Setup\\": "setup/src/Magento/Setup/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/",
            "Magento\\Tools\\": "dev/tools/Magento/Tools/",
            "Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/",
            "Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
            "Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/",
            "Magento\\ToolkitFramework\\": "dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/"
        }
    },
    "minimum-stability": "alpha",
    "prefer-stable": true
}

2 个答案:

答案 0 :(得分:1)

希望这会有所帮助。首先,您是否克隆了样品回购?

如果是,则cd到要安装并运行的示例的目录:

composer install

那应该安装模块。如果要安装所有模块,请备份一个目录并运行composer install

答案 1 :(得分:0)

我相信你的问题是因为你试图要求一个没有稳定版本(即标记)的软件包。

你可以告诉作曲家你很乐意以几种方式安装dev稳定包。您可以通过手动将其添加到"require"中的composer.json媒体资源,将其仅用于此套餐...

"magento/sample-module-newpage": "dev-master"

或者你可以通过添加这个root属性告诉composer允许在composer.json中列出的所有包中使用dev稳定包...

"minimum-stability": "dev"

更新composer.json文件后,您需要通过执行composer update magento/sample-module-newpage

来获取该包