├── Block
└── HelloWorld.php
├── Controller
└── Index
│ └── Index.php
├── README.md
├── composer.json
├── etc
├── frontend
│ └── routes.xml
└── module.xml
├── registration.php
└── view
└── frontend
├── layout
└── helloworld_index_index.xml
└── templates
└── helloworld.phtml
/Block/HelloWorld.php:
--------------------------------------------------------------------------------
1 | resultPageFactory = $resultPageFactory;
21 | parent::__construct($context);
22 | }
23 |
24 | /**
25 | * Default customer account page
26 | *
27 | * @return void
28 | */
29 | public function execute()
30 | {
31 | return $this->resultPageFactory->create();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | #Magento 2 Controller Module Example
2 |
3 | From my blog post: https://www.ashsmith.io/2014/12/simple-magento2-controller-module/
4 |
5 | ## To install:
6 |
7 | Install with Composer!
8 |
9 | composer require ashsmith/magento2-controller-module:2.0.*
10 |
11 | Then you'll need to modify `app/etc/config.php` to activate the module. It should look a little like this:
12 |
13 |
16 | array (
17 | ...
18 | 'Ashsmith_HelloWorld' => 1,
19 | ),
20 | );
21 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ashsmith/magento2-controller-module",
3 | "description": "A basic Magento 2 module with a controller",
4 | "type": "magento2-module",
5 | "version": "2.0.1",
6 | "license": [
7 | "OSL-3.0",
8 | "AFL-3.0"
9 | ],
10 | "require": {
11 | "php": "~5.5.0|~5.6.0|~7.0",
12 | "magento/magento-composer-installer": "*"
13 | },
14 | "extra": {
15 | "map": [
16 | [
17 | "*",
18 | "Ashsmith/HelloWorld"
19 | ]
20 | ]
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/etc/frontend/routes.xml:
--------------------------------------------------------------------------------
1 |
We created a block! Our block class is: !
4 | --------------------------------------------------------------------------------