Skip to content

Latest commit

 

History

History
83 lines (70 loc) · 2.83 KB

3.x-4.x.md

File metadata and controls

83 lines (70 loc) · 2.83 KB

3.x to 4.x

Routing

Removed the following methods on group: group, route, middlewares, middleware, pathOptions, use additional parameters. Removed the following methods on route: middlewares, middleware, pathOptions, use additional parameters.

from

Group::create('/{id}')
    ->pathOptions(['tokens' => ['id' => '\d+']])
    ->middleware($middleware1)
    ->route(Route::get('/{slug}', 'element_read', $handler)
        ->pathOptions(['tokens' => ['slug' => '[a-z]+']])
        ->middleware($middleware2)
    )
    ->group(Group::create('/{slug}')
        ->pathOptions(['tokens' => ['slug' => '[a-z]+']])
        ->middlewares([$middleware2])
        ->route(Route::get('/{key}', 'another_route', $handler)
            ->pathOptions(['tokens' => ['key' => '[a-z]+']])
            ->middleware($middleware3)
        )
    )
    ->route(Route::get('/{slug}/{key}/{subKey}', 'yet_another_route', $handler)
        ->pathOptions(['tokens' => ['slug' => '[a-z]+', 'key' => '[a-z]+', 'subKey' => '[a-z]+']])
        ->middleware($middleware2)
    )
;

to

Group::create('/{id}', [
    Route::get(
        '/{slug}',
        'element_read',
        $handler,
        [$middleware2],
        ['tokens' => ['slug' => '[a-z]+']]
    ),
    Group::create('/{slug}', [
        Route::get(
            '/{key}',
            'another_route',
            $handler,
            [$middleware3],
            ['tokens' => ['key' => '[a-z]+']]
        ),
    ], [$middleware2], ['tokens' => ['slug' => '[a-z]+']]),
    Route::get(
        '/{slug}/{key}/{subKey}',
        'yet_another_route',
        $handler,
        [$middleware2],
        ['tokens' => ['slug' => '[a-z]+', 'key' => '[a-z]+', 'subKey' => '[a-z]+']]
    ),
], [$middleware1], ['tokens' => ['id' => '\d+']]);

The router Chubbyphp\Framework\Router\RouterInterface was splitted into:

  • Chubbyphp\Framework\Router\RouteMatcherInterface (match routes)
  • Chubbyphp\Framework\Router\UrlGeneratorInterface (generate url)

Move of Chubbyphp\Framework\Router\RouterException to Chubbyphp\Framework\Router\Exceptions\RouterException.

RouteGenerationException replaces

  • Chubbyphp\Framework\Router\Exceptions\MissingAttributeForPathGenerationException
  • Chubbyphp\Framework\Router\Exceptions\NotMatchingValueForPathGenerationException

ErrorHandler

ErrorHandler will be removed (convert php error to exception), cause it forces exceptions in libraries trigger_error is used without silence it. See: lcobucci/jwt#563 If you don't mind i suggest to copy the code from 3.x to your project, adapt the namespace and use your implementation.

Application

Construct signature changes (only relevant if you override the defaults) from ($middleware, $middlewareDispatcher, $emitter) to ($middleware, $middlewareDispatcher, $requestHandler, $emitter)