I'm new on Drupal. I try to follow a tuto in order to build my own module.
Drupal 8 (latest version) is installed on MacOS. For example, I use it through URL : http://localhost/drupal/admin/content
My module is defined like this :
- Drupal
- code
- modules
- hello_world
- hello_world.info.yml
- hello_world.links.menu.yml
- hello_world.routing.yml
- src
- Controller
- HelloController.php
- Controller
- src
- hello_world
- ...
File content : hello_world.info.yml
name: Hello World Module
description: Creates a page showing "Hello World".
package: Custom
type: module
version: 1.0
core: 8.x
File content : hello_world.routing.yml
hello_world.hello_world:
path: '/hello'
defaults:
_controller: '\Drupal\hello_world\Controller\HelloController::helloWorld'
_title: 'Hello World'
requirements:
_permission: 'access content'
File content : hello_world.links.menu.yml
hello_world.admin:
title: 'Hello module settings'
description: 'example of how to make an admin settings page link'
parent: system.admin_config_development
route_name: hello_world.hello_world
weight: 100
File content : HelloController.php
<?php
/**
* @file
* Contains \Drupal\hello_world\Controller\HelloController.
*/
namespace Drupal\hello_world\Controller;
use Drupal\Core\Controller\ControllerBase;
/**
* Defines HelloController class.
*/
class HelloController extends ControllerBase {
/**
* Display the markup.
*
* @return array
* Return markup array.
*/
public function helloWorld() {
$output = array();
$output['hello_world'] = array(
'#markup' => $this->t('Hello World!'),
);
return $output;
}
}
Regardless "clear cache", I have a page not found !
I try the urls :
But results are the same. What should be the right url ? And why I'm getting "page not found", where is the issue ?