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

v2 to v3

David's Avatar

David

27 Jan, 2016 03:05 PM

Hi,
In my v2 project i was using this structure :

function echoRespnse($status_code, $response, $request) {
   $app = \Slim\Slim::getInstance(); <-------ERR
    $response = $request->getParsedBody();
    $app->status($status_code);
    $app->contentType('application/json');

    echo utf8_encode(json_encode($response));
}

Someone got a tip for me how to replace $app = \Slim\Slim::getInstance(); properly in v3?

Thanks

  1. 1 Posted by Rob Allen on 27 Jan, 2016 06:29 PM

    Rob Allen's Avatar

    Set the $response object and return it in v3. Use $this->get('serviceName') to get objects from the DI container.

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