Best way to exit after response / flow control

Dear Slim Team

Let’s assume a simple route like this:

$app->post('/ticket/new', function (Request $request, Response $response) use ($cfgAPI) {
    doing stuff here

   $response->getBody()->write("we are done");
   return $response;

If I put in some conditional logic inside this route - what is the best practice to exit if some condition is reached?

simple condition
if ($a == “yes”) {
$response->getBody()->write(“done case yes”);
return $response;
} else {
$response->getBody()->write(“done case no”);
return $response;

But if I have more complex conditions, the following way would be nice - but is this allowed/supported? I saw halt/stop is removed in V3:

if ($a == "yes") {
   $response->getBody()->write("done case yes");
   return $response;
   AND DO NOT PROCESS FURTHER exit/halt/stop here

…and more logic…
…and more logic…

Sorry, but I can’t find this in the docs.
Thanks for helping out!

Yes, that is indeed what will happen. I use it fairly often and I believe the technique is called “early return”. Once you return the $response you’re done. Slim will process any remaining middleware, etc, but so far as that action is concerned nothing further gets processed.

I see, an option would be great to have no middleware processed further as well.

…but I can work around this.

If you don’t setup any middleware no further processing Take Place