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

notFound handler

Sam Levin's Avatar

Sam Levin

28 May, 2015 04:15 AM

I was checking out the notFound handler again today, and I'd noticed that the 'halt' is still getting fired after a user-set closure is invoked. Is there any way you can only fire that if the DEFAULT notFound is invoked? I want things to finish up when I run my own notFound handler (middleware etc, debugging, tracing), and when RESTing, I also return a non-404 value.
I remember there being a github issue on this that says 'fixed in dev branch'. Does that mean the fix won't be present until Slim 3? At the moment, I'm using 2.4.2 hard-coded into my 'meta framework' (with that notFound handler halt commented out) as opposed to grabbing latest from the repo.

  1. 1 Posted by herman on 31 May, 2015 02:21 PM

    herman's Avatar

    in slim3 we can defined not found hendler in container, please check document for detail:
    http://docs-new.slimframework.com/handlers/not-found/


    $c = new \Slim\Container();

    $c['notFoundHandler'] = function ($c) { return function ($request, $response) use ($c) { return $c['response']->withStatus(404) ->withHeader('Content-Type', 'text/html') ->write('Page not found'); }; };

    $app = new Slim\App($c);

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