PHP code example of hickeroar / zf2-route-inheritance

1. Go to this page and download the library: Download hickeroar/zf2-route-inheritance library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hickeroar / zf2-route-inheritance example snippets


'router' => [
    'routes' => [
        'my-original-route' => [
            'type' => 'literal',
            'options' => [
                'route'    => '/orig-url',
                'defaults' => [
                    'controller' => 'Application\Controller\IndexController',
                    'action'     => 'index',
                ],
            ],
        ],
    ],
    // "Copies" my-original-route to my-new-route and overrides/adds various things.
    // This currently uses a merge, so removing config keys is not supported.
    'inheritance' => [
        'my-new-route' => [
            'extends' => 'my-original-route',
            'configuration' => [
                'type' => 'segment',
                'options' => [
                    'route'    => '/new-url/:segment',
                    'constraints' => [
                        'segment' => '[a-zA-Z0-9_-]+',
                    ],
                    'defaults' => [
                        'controller' => 'Application\Controller\IndexController',
                        'action'     => 'new',
                    ],
                ],
            ],
        ],
    ],
],