Slim doesn't redirect

I just begginer in Slim framework V2 and in my actual new project i’m trying to do a redirects like this:

$app->get('/', function() use ($app) {

$app->get('/flash', function()  use ($app) {

    $app->flash('registerFlash', 'You have registred!!!');
    $app->response->redirect($app->urlFor('home'), 301);

But the Slim doesn’t redirect. I try to use the $app->redirect($app->urlFor(‘home’), 301); function as discribed in but doesn’t work too.
Any idea, whats wrong with my redirects?


I don’t know what’s wrong with your code, as I’ve never used Slim V2, but if you’re starting a new project, my strong suggestion would be to go with Slim V3. There’s really no point in using an outdated version of the framework for a new project.


Thaks for your suggestion! I will change to the version 3.

I discover a wrong require file in my code.

Not sure what you’re doing, but given that Slim is all autoloader based, you should not need any require statements for classes. The only requires I have are the ones for settings, routes, dependencies and middleware. Anything else is loaded by the autoloader.