The Slim Framework support forum has moved to http://discourse.slimframework.com. This Tender forum is no longer maintained or monitored.

Slim3 - How to redirect to route?

dooks's Avatar

dooks

28 Jul, 2015 12:14 PM

Hello, I have a problem redirecting to another route. I'm using akrabat/slim3-skeleton

I have:

$app->get('/dosomething/{id}', function ($request, $response, $args) {
     // do something
     //.....
     $this->redirect('/'.$args['id']);
});

What's the correct way to redirect to a route because it doesn't work like this?

Thanks!

  1. Support Staff 1 Posted by Andrew Smith on 29 Jul, 2015 10:25 AM

    Andrew Smith's Avatar

    In Slim 3 you have to use the Response object for redirects.

    $app->get('/dosomething/{id}', function ($request, $response, $args) { 
         // do something 
         //..... 
         return $response->withRedirect('/'.$args['id']); 
    });
    

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac