Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flexible routing #304

Closed
wants to merge 4 commits into from
Closed

Conversation

imehdihosseini
Copy link

Sometimes i need to create a route which the route name is not related to controller name, i created the withFlex() method to handle this action, is there another way to do this?

$klein->withFlex( 'TestController', '/test-route', function () use ($klein) {

    $klein->respond('GET', '/?', function ($request, $response, $service, $app) {

        return $app->controller->index();

    });

    $klein->respond( 'GET', '/[:id]', function ($request, $response, $service, $app)  {

        return $app->controller->show( $request->id( false ) );

    });

});

@Rican7
Copy link
Member

Rican7 commented Feb 1, 2017

This is an impressive feature! Unfortunately, it's using quite a bit of magic regarding controller class initialization and such, which moreso belongs in a framework than it does in Klein's more basic routing system. Sorry. 😞

@Rican7 Rican7 closed this Feb 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants