Skip to content

Instantly share code, notes, and snippets.

@geggleto
Created January 26, 2016 22:29
Show Gist options
  • Save geggleto/856a8b291c62ccfe7c50 to your computer and use it in GitHub Desktop.
Save geggleto/856a8b291c62ccfe7c50 to your computer and use it in GitHub Desktop.
slim 3 gist 7
<?php
$app->add(function ($req, $res, $next) {
//DO SOMETHING BEFORE THE REQUEST IS PROCESSED
$res = $next($req, $res); //PROCESS THE REQUEST
//DO SOMETHING AFTER THE REQUEST HAS BEEN PROCESSED
if ($res->getStatusCode() > 500) {
//Do something with a server error, maybe email someone or submit a bug report
}
//Continue rendering
return $res;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment