The Slim Framework support forum has moved to This Tender forum is no longer maintained or monitored.

Validating Data using GUMP

Joe Kane's Avatar

Joe Kane

01 Mar, 2012 07:52 AM

hi, I wanted to incorporate [GUMP] ( into my Slim rest framework.

I am looking to intercept a GET or POST request before validating it with GUMP before continuing to process. Could you provide a brief snippet of code as I was unable to figure it out using middleware (server is on php 5.2).

Many thanks

  1. Support Staff 1 Posted by Josh Lockhart on 24 Mar, 2012 07:49 PM

    Josh Lockhart's Avatar

    Version 1.6.0 will provide a more full-featured middleware implementation soon. For now, in either the stable or develop branch, you can do something like this:

    $app = new Slim();
    function validateRequest() {
        $app = Slim::getInstance();
        $req = $app->request();
        $condition = true; //<-- Perform validation here
        if ( $condition !== true ) {
            $app->halt(400, 'Bad request'); //<-- Or you can redirect
    $app->get('/foo', 'validateRequest', function () {
        echo "Your request is valid!";

    Hope this helps.

  2. Josh Lockhart closed this discussion on 24 Mar, 2012 07:49 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? 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