PHP code example of chris-kruining / zf3-extensions

1. Go to this page and download the library: Download chris-kruining/zf3-extensions 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/ */

    

chris-kruining / zf3-extensions example snippets


return [
    ...
    'router' => [
        'router_class' => \CPB\Extensions\Zend\Router\FilterableTreeRouteStack::class,
        'route_error_callback' => [
            'controller' => \Your\Own\Controller::class,
        ],
        'routes' => [
            'sale' => [
                'type'=> 'Segment',
                'filter' => <CALLABLE>,
                'options'=> [
                    'route' => '/sale[/:id]',
                    'constraints' => [
                        'id' => '\d+'
                    ],
                    'defaults' => [
                        'controller' => \Your\Own\Controller::class,
                        'id' => 0,
                    ],
                ],
                'may_terminate' => false,
                'child_routes' => [
                    'discover' => [
                        'type' => 'Method',
                        'options' => [
                            'verb' => 'options,head',
                            'defaults' => [
                                'action' => 'list',
                            ],
                        ],
                    ],
                    'read' => [
                        'type' => 'Method',
                        'options' => [
                            'verb' => 'get',
                            'defaults' => [
                                'action' => 'read',
                            ],
                        ],
                    ],
                    'create' => [
                        'type' => 'Method',
                        'options' => [
                            'verb' => 'post',
                            'defaults' => [
                                'action' => 'create',
                            ],
                        ],
                    ],
                ],
            ],
        ]
    ],
    ...
];