Kebab-case URL management plugin


1Presentation

This plugin is used to manage URLs in “kebab case” format, with elements separated by dashes.

Examples:

  • /my-controller is used instead of /myController
  • /my-controller/an-action is used instead of /myController/anAction

This processing applies to controller and action names, but not to parameters.

Example:

  • /my-controller/an-action/a-parameter replaces /myController/anAction/a-parameter

When this plugin is activated, a 404 error is generated if the controller or action name contains an uppercase character.

Please note that this plugin adds processing on character strings. This processing is negligible on the scale of a single request, but can have an impact on high-traffic sites.


2Configuration

In the etc/temma.php file, simply add the prepllugin:

<?php

return [
    // loading the plugin
    'plugins' => [
        '_pre' => [
            '\Temma\Plugins\KebabCaseUrl'
        ]
    ]
];