I’m using Drupal 8.0.1. Just I’m started to develop a custom module to simply show hello world text in /first path. Here is my code.
FirstController.php [It is in the path sites/all/modules/first_module/src/Controller]
namespace Drupalfirst_moduleController; use DrupalCoreControllerControllerBase; class FirstController extends ControllerBase { public function content() { return array( '#type' => 'markup', '#markup' => t('Hello world'), ); } }
first_module.routing.yml [It is in the path sites/all/modules/first_module]
first_module.content: path: '/first' defaults: _controller: 'Drupalfirst_moduleControllerFirstController::content' _title: 'Hello world' requirements: _permission: 'access content' _permission: 'view first'
first_module.info.yml [It is in the path sites/all/modules/first_module]
name: First Module description: An experimental module to build our first Drupal 8 module package: Custom type: module version: 1.0 core: 8.x
I can able to see my custom module in http://localhost/admin/modules also I can able to install the module. But when I got to the path http://localhost/first it shows the error
ReflectionException: Class Drupalfirst_moduleControllerFirstController does not exist in /home/aaa/Public/drupal-8.0.1/core/lib/Drupal/Core/Entity/EntityResolverManager.php on line 128, referer: http://d8.localhost/admin/modules
Where I would went wrong?? Any help!!!
Sponsored by SupremePR