How do I implement routes? How can I implement the most basic route in Drupal 8? What files do I have to write, and which classes do I need to implement?
Implementing the most basic route in Drupal 8 require:


The file containing the routing definitions (helloworld.routing.yml)

helloworld.hi:
  pattern: '/helloworld'
  defaults:
    _controller: '\Drupal\helloworld\Controller\HelloWorldController::hi'
  requirements:
    _permission: 'access content'

A controller class that returns a render array or a string (src/Controller/HelloWordCOntroller.php)

namespace Drupal\helloworld\Controller;

class HelloWorldController {
  function hi() {
    return 'Hello world!';
  }
}



This is the equivalent of what in Drupal 7 was a MENU_CALLBACK. Implementing a local task, or a local action requires other files to be added, differently from Drupal 7, where a local tab would be implemented using the same hook used for a MENU_CALLBACK.