phpframeworksexecutionslimhalt

SLIM framework Halt call


Have a question on Slim Framework php.

In my application, I would like to stop the application execution if a condition is mismatched.

There is a halt function, per Slim documentation. But that does not appear to be working. the application continuous to execute even after calling Halt.

pseudo code:

if ( $valid ) {
         // Do something
} else {
    $app->halt(500, "not valid");
}
// Other code here.


$app->run();

I was expecting that, we we call Halt function, the "Other code" should not execute. But it does not appear to be the case.

Any ideas?


Solution

  • You can always call exit manually to stop the script execution.

    $app->halt(500, "not valid");
    exit;