1. Go to this page and download the library: Download dogancelik/slim-json library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dogancelik / slim-json example snippets
$app = new \Slim\Slim();
// Add the middleware globally
$app->add(new \SlimJson\Middleware(array(
'json.status' => true,
'json.override_error' => true,
'json.override_notfound' => true
)));
$app->get('/', function() use ($app) {
$app->render(200, ['Hello' => 'World']);
});
$app->get('/error', function() use ($app) {
throw new \Exception('This is an error');
});
$app->run();