Skip to content

Instantly share code, notes, and snippets.

@prasadshir
Last active May 9, 2020 07:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save prasadshir/be232c55197c5011b074ea4efa1f416d to your computer and use it in GitHub Desktop.
Save prasadshir/be232c55197c5011b074ea4efa1f416d to your computer and use it in GitHub Desktop.
D728 Task-01: Create a custom page
<?php
/**
* Controller file for Lotus Drupal 8 module.
* Place this file in src/Controller folder inside the lotus module folder
**/
namespace Drupal\lotus\Controller;
use Drupal\Core\Controller\ControllerBase;
class HelloController extends ControllerBase {
public function content() {
return array(
'#type' => 'markup',
'#markup' => $this->t('Welcome to my website!'),
);
}
}
name: Lotus
type: module
description: Lotus module for learning Drupal 8 from Drupal 7 experience
core: 8.x
package: Acquia Learning
# Ruting file for the Lotus module in Drupal 8.
# Add this to the root of the module folder,
# e.g. modules/custom/lotus/lotus.routing.yml
lotus.content:
path: '/hello'
defaults:
_controller: '\Drupal\lotus\Controller\HelloController::content'
_title: 'Hello Drupal!'
requirements:
_permission: 'access content'
@jmolivas
Copy link

jmolivas commented Jun 8, 2017

@prasadshir any plans to add a section How to generate using DrupalConsole

I am adding an snipped as example:

Generate module

Interactive mode

drupal generate:module

Inline mode

drupal generate:module \
--module="Lotus" 
--machine-name="lotus" \
--module-path="/modules/custom"  \
--description="Lotus module for learning Drupal 8 from Drupal 7 experience" \
--core="8.x" 
--package="Acquia Learning" \
--no-interaction 

@eliasdelatorre
Copy link

eliasdelatorre commented Apr 26, 2019

Thanks, I was looking for a way of doing it with Console. Keep up the good work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment