zfcampus / zf-versioning

BSD 3-Clause "New" or "Revised" License
11 stars 7 forks source link

Use version param from route if exists #9

Closed kanellov closed 9 years ago

kanellov commented 9 years ago

I'm having the same problem with @bvarent as described in #8. In order to get over it I've changed the PrototypeRouteListener class in order to use the existing route version param if exists. With this you can specify the placement of the version in the url.

e.g. The following configuration will produce /api/v1/user* urls

$routes = array(
    'api' => array(
        'type' => 'Segment',
        'options' => array(
            'route' => '/api[/v:version]',
        ),
        'child_routes' => array(
            'user' => array(
                'type' => 'Segment',
                    'options' => array(
                        'route' => '/user[/:id]',
                        'defaults' => array(
                            'controller' => 'UserController',
                        ),
                    ),
                ),
            ),
        ),
    ),
);
kanellov commented 9 years ago

php-cs-fixer fails in travis

TomHAnderson commented 9 years ago

I think this is a very poor implementation of what has already been solved using Media Type Versioning. It's like you saw someone else' years-out-of-date API and decided it was easiest enough for you to implement.

https://apigility.org/documentation/api-primer/versioning I can't imagine any scenario where Media Type Versioning isn't superior to url params.

kanellov commented 9 years ago

I agree with you @TomHAnderson, Media Type versioning is better. The change I propose does not affect module's default operation. It just enables the version param positioning in url with the minimum effort.

TomHAnderson commented 9 years ago

Yours is not the easy solution, it is the wrong solution. Just because it's easy doesn't make it right.