PHPackages                             m2demo/module-m2-extension - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. m2demo/module-m2-extension

ActiveMagento2-module

m2demo/module-m2-extension
==========================

Bare-bones demo extension

v2.0(11y ago)38547PHPPHP ~5.4.11|~5.5.0

Since Dec 16Pushed 11y ago10 watchersCompare

[ Source](https://github.com/coldgreentea/m2extension)[ Packagist](https://packagist.org/packages/m2demo/module-m2-extension)[ RSS](/packages/m2demo-module-m2-extension/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Reference Module
================

[](#reference-module)

Thank you for trying the Magento reference module! We created it to get you started with module development as quickly as possible. Right now it simply displays a list of Magento modules but you can use it to:

- See the basic components of a Magento module and where they belong
- Do a quick installation
- See it work

Installing and verifying the reference module
---------------------------------------------

[](#installing-and-verifying-the-reference-module)

You can install the reference module in any of the following ways:

1. By copying the code to your `/app/code//` directory.
    This method requires some manual tasks but it easy.
2. Using `composer update`.

### Installing the module by copying code

[](#installing-the-module-by-copying-code)

Any Magento module requires a particular directory structure under `/app/code`. The structure starts with:

```
/

```

The reference module requires the following structure:

```
M2demo/M2Extension

```

To add the module to your Magento installation:

1. Log in to your Magento server as a user with privileges to write to the web server docroot (typically either the `root` user or the web server user).
2. Enter the following commands in the order shown:

    ```
     cd /app/code
     mkdir -p M2demo/M2Extension

    ```
3. Go to the [reference module GitHub](https://github.com/coldgreentea/m2extension).
4. Click **Download Zip**.
5. Copy the `.zip` file you downloaded to your Magento server's `/app/code/m2demo/module-m2-extension` directory.
6. Enter the following commands in the order shown:

    ```
     unzip m2extension-master.zip
     mv m2extension-master/* .
     rm -rf m2extension-master

    ```
7. Open `/app/etc/config.php` in a text editor.
8. Add the following anywhere under: `'modules' => array (`:

    ```
    'M2Demo_M2Extension' => 1

    ```
9. Save your changes and exit the text editor.

### Installing the module using Composer

[](#installing-the-module-using-composer)

To install any module using `composer update`, you must modify the Magento 2 `composer.json`. The changes required for the reference module are simple, and after that it installs automatically.

To use Composer to install the module:

1. Log in to your Magento server as a user with `root` privileges.

    **Note**: On Ubuntu, you might need to use the `sudo su` command.
2. Change to your Magento installation directory.
3. Open `composer.json` in a text editor.
4. Add the following line in the `"require":` section:

    ```
    "m2demo/module-m2-extension": "*"

    ```

    **Note**: Make sure the preceding line ends with a comma character.
5. In the `autoload": { "psr-4"` section, add the following line:

    ```
    "M2Demo\\": "app/code/M2Demo/"

    ```

    **Note**: Make sure the preceding line ends with a comma character.
6. Save your changes and exit the text editor.
7. From your Magento installation directory, enter the following commands in the order shown:

    ```
    composer dump-autoload
    composer update

    ```

### Verifying the reference module

[](#verifying-the-reference-module)

1. Log in to your Magento server as a user with `root` privileges.
2. Enter the following commands in the order shown to clear the Magento cache:

    ```
     cd /var
     rm -rf cache page_cache

    ```
3. If you're currently logged in to the Magento Admin, log out.
4. Log in to the Magento Admin as an administrator.
5. Click **Stores** &gt; **Configuration** &gt; ADVANCED &gt; **Advanced** &gt; **Disable Modules Output**.

If **m2demo\_module-m2-extension** displays in alphabetical order, you successfully installed the reference module!

To see the reference module at work, enter the following URL in your browser's address or location field:

```
	http[s]:////demo_extension/index/sayhello

```

For example:

```
	http://www.example.com/magento/demo_extension/index/sayhello

```

A list of Magento modules displays. That's it! You're done!

Components
----------

[](#components)

### composer.json

[](#composerjson)

#### Root

[](#root)

To autoload classes in the module more quickly, the root composer.json must be updated. Place the following line in the autoload-&gt;psr-4 section:

```
"M2Demo\\": "app/code/M2Demo/"

```

For reference, see [Composer's autoloading documentation.](https://getcomposer.org/doc/01-basic-usage.md#autoloading)

#### Module

[](#module)

To integrate the module with composer, a composer.json file must be placed in the root of the extension.

### Routing

[](#routing)

A router takes the given request and determines which controller and action should handle it. Routing options are configured in "etc/\*\*\*\*routes.xml" (relative to extension root).

#### Router

[](#router)

The **router** element's **id** attribute determines which router to use for this module.

#### Route

[](#route)

The **route** element's **id** attribute provides a unique name for the router and module pair. Used for merging config information of multiple routers.

#### Frontname

[](#frontname)

The **module** element's **frontname** attribute is what will show up in the url corresponding to the module.

#### Area

[](#area)

During runtime, one of several **areas** is always active, depending on the type of user and code being executed. This module is meant for the **frontend** area. The directory structure is: Extension/etc/**area**/routes.xml

### module.xml

[](#modulexml)

The module.xml file defines the name of the module. If any of the module's dependencies need to be loaded in a particular sequence, this file can also store that sequence.

### Controller

[](#controller)

The controller class is in app/code/M2Demo/M2Extension/Controller/Index/SayHello.php.

#### URL

[](#url)

The controller is accessed at the URL /demo\_extension/index/sayhello

- **demo\_extension** is the frontname of the module
- **index** is the namespace of the controller (slightly different from the namespace of the class but related).
- **sayhello** is the action name.

#### Code

[](#code)

The controller class extends \\Magento\\Framework\\App\\Action\\Action. It implements an **execute()** method, which contains the controller's business logic. In this case, it prints out a short message and a list of active modules. If it renders output, the output must go into the **\_response** object.

#### Response

[](#response)

The **\_response** object stores the information that is sent back to the client. It is a protected member of the class defined by a parent.

#### Parent

[](#parent)

The parent's **dispatch()** method calls **execute()**, and then returns the **\_response** back to the system, which delivers it to the client.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

4160d ago

Major Versions

1.0 → v2.02014-12-18

### Community

Maintainers

![](https://www.gravatar.com/avatar/67604f20a04746ffaecedcecc44edf37713beea5ecfbedd8233dcee5269a0d23?d=identicon)[coldgreentea](/maintainers/coldgreentea)

---

Top Contributors

[![ArnaudLigny](https://avatars.githubusercontent.com/u/80580?v=4)](https://github.com/ArnaudLigny "ArnaudLigny (1 commits)")[![MartinPeverelli](https://avatars.githubusercontent.com/u/2745975?v=4)](https://github.com/MartinPeverelli "MartinPeverelli (1 commits)")

### Embed Badge

![Health badge](/badges/m2demo-module-m2-extension/health.svg)

```
[![Health](https://phpackages.com/badges/m2demo-module-m2-extension/health.svg)](https://phpackages.com/packages/m2demo-module-m2-extension)
```

###  Alternatives

[magento/community-edition

Magento 2 (Open Source)

12.1k52.1k10](/packages/magento-community-edition)[smile/elasticsuite

Magento 2 merchandising and search engine built on ElasticSearch

8044.5M33](/packages/smile-elasticsuite)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[vpietri/adm-quickdevbar

QuickDevBar is a developer toolbar for magento 2

577348.6k](/packages/vpietri-adm-quickdevbar)[msp/devtools

222629.1k2](/packages/msp-devtools)[msp/cmsimportexport

76510.8k](/packages/msp-cmsimportexport)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
