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

Slim 2, Problem with Redirect from Middleware

Takdown's Avatar

Takdown

03 Sep, 2015 03:54 PM

As the title says, I canno't redirect to a specific route from a middleware..I get an error from my browser, "This web page is a redirect loop" something like that...if I can get some help.Thank you very much!

The code:

<?php

namespace Hass\Middleware;

class BeforeMiddleware extends \Slim\Middleware
{
public function call()
{

$this->install();
$this->next->call();
}

public function install()
{
$config = json_decode(file_get_contents('../app/config/database.json'));

if ($config->connection == 0)
{

return $this->app->response()->redirect($this->app->urlFor('get.finish'));
}
}
}

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