Please Disable Your Browser Adblock Extension for our site and Refresh This Page!

our ads are user friendly, we do not serve popup ads. We serve responsible ads!

Refresh Page
Skip to main content
On . By CodimTh

Drupal 8's routes may include placeholder elements which designate places where the URL contains dynamic values. In the controller method, this value is available when a variable with the same name is used in the controller method.

For example in mymodule.routing.yml:

  path: '/mymodule/{name}'
    _controller: '\Drupal\mymodule\Controller\MyModuleController::content'
    _permission: 'access content'

The {name} element in the URL is called a slug and is available as a $name in the content method.


namespace Drupal\mymodule\Controller;

use Drupal\Core\Controller\ControllerBase;

 * Class MyModuleController
 * @package Drupal\mymodule\Controller
class MyModuleController extends ControllerBase

   * @param $name
   * @return array
  public function content($name)
    return [
      '#type' => 'markup',
      '#markup' => $this->t('Hello @name .', array('@name' => $name)),



Add new comment

Restricted HTML


Page Facebook

Become a patron

If you need some help or you search a Drupal freelancer don't hesitate to contact us.


Contact Us

All the content is FREE but I still need your help


Become a patreon