[ONLY Magento 2.0.x Compatible] Code samples for Magento developers
PHP HTML JavaScript CSS
Switch branches/tags
Nothing to show
Clone or download
maksek Merge pull request #84 from piotrekkaminski/patch-1
Update README with note about 2.0-only compatibility
Latest commit a590d01 May 9, 2017
Permalink
Failed to load latest commit information.
module-sample-scss MAGETWO-48081: Copyright Year Update Mar 18, 2016
sample-bundle-all MAGETWO-48081: Copyright Year Update Mar 18, 2016
sample-ee-bundle-all MAGETWO-48081: Copyright Year Update Mar 17, 2016
sample-external-links MAGETWO-55017: Create sample module which adds extension attribute to… Jul 15, 2016
sample-module-command MAGETWO-48081: Copyright Year Update Mar 17, 2016
sample-module-custom-deployment-config MAGETWO-48081: Copyright Year Update Mar 17, 2016
sample-module-form-uicomponent MAGETWO-48081: Copyright Year Update Mar 17, 2016
sample-module-interception MAGETWO-48081: Copyright Year Update Mar 18, 2016
sample-module-minimal MAGETWO-48081: Copyright Year Update Mar 18, 2016
sample-module-modifycontent MAGETWO-48081: Copyright Year Update Mar 17, 2016
sample-module-newpage MAGETWO-48081: Copyright Year Update Mar 17, 2016
sample-module-payment-gateway MAGETWO-48081: Copyright Year Update Mar 18, 2016
sample-module-sample-message-queue Merge remote-tracking branch 'mainline/master' Mar 28, 2016
sample-module-service-contract-client MAGETWO-48081: Copyright Year Update Mar 18, 2016
sample-module-service-contract-replacement MAGETWO-48081: Copyright Year Update Mar 18, 2016
sample-module-servicecontract-new MAGETWO-48081: Copyright Year Update Mar 17, 2016
sample-module-shipping-provider MAGETWO-48081: Copyright Year Update Mar 18, 2016
sample-module-theme MAGETWO-48081: Copyright Year Update Mar 18, 2016
sample-module-webapi-client MAGETWO-48081: Copyright Year Update Mar 18, 2016
sample-module-webflow MAGETWO-48081: Copyright Year Update Mar 18, 2016
LICENSE.txt MAGETWO-32792: Creation of m2-sample-minimal extension Feb 3, 2015
LICENSE_AFL.txt MAGETWO-48081: Copyright Year Update Mar 18, 2016
README.md Update README with note about 2.0-only compatibility May 8, 2017

README.md

The sample code included in this repository was developed for Magento 2.0.x. Please be aware of this, and also know that PRs are welcomed to help us improve and/or update the 2.0.x code samples and extensions! We welcome your feedback and ideas about also creating a series of 2.1.x code examples; in our shared reality of constrained resources and a million fun projects to work on, we acknowledge that it will take some time for us to provide the 2.1.x samples.

Synopsis

This project is a collection of samples to demonstrate technologies introduced in Magento 2. You will find the most simple extension along with samples that incrementally add features to lead you through a exploration and education of the Magento 2 platform.

Motivation

The intent is to learn by example, following our best practices for developing a modular site using Magento 2.

Installation

Each sample is packaged and available individually at repo.magento.com. For convenience and demonstration of our bundling of modules, we have included the sample-bundle-all composer metapackage. Including this dependency in your Magento project is the more convenient way to integrate the full set of examples. Refer to that sample for more detailed installation instructions.

To install any of these samples, you'll need to be sure that your root composer.json file contains a reference to the repository that contains them. To do so, add the following to composer.json:

    "repositories": [
        {
            "type": "composer",
            "url": "http://repo.magento.com/"
        }
    ]

The above can also be added using the Composer command line with the command:

composer config repositories.magento composer http://repo.magento.com/

Registration

New in Magento 2 is the ability to register modules to install anywhere under the Magento root directory; typically, under the vendor subdirectory.

All sample modules have a registration.php in their root directory with contents similar to the following:

<?php
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Magento_CommandExample',
    __DIR__
);

The preceding example registers the Magento_CommandExample component to install under Magento's vendor directory. For more information about component registration, see the PHP Developer's Guide.

In addition, each module's composer.json references registration.php in its autoload section as follows:

{
  "name": "magento/sample-module-command",
  "description": "Command example",
  "type":"magento2-module",
  "require": {
    "php": "~5.5.0|~5.6.0|~7.0.0"
  },
  "version": "1.0.0",
  "autoload": {
    "files": [ "registration.php" ],
    "psr-4": {
      "Magento\\CommandExample\\": ""
    }
  }
}

PSR-4 section

Each module's composer.json has a psr-4 section except for sample-module-theme. Themes don't require it because they do not reference

Contributors

Magento Core team

License

Open Source License