PHP code example of aalfiann / slim-api-skeleton

1. Go to this page and download the library: Download aalfiann/slim-api-skeleton 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/ */

    

aalfiann / slim-api-skeleton example snippets


use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

// Route for /my-app
$app->group('/my-app', function($app) {

    // Show index page
    // Try to open browser to http://yourdomain.com/my-app/
    $app->get('/', function (Request $request, Response $response) {
        $data = [
            'welcome' => 'Hello World, this is my-app index page.',
            'message' => 'This is my first app rest api with slim-api-skeleton.'
        ];
        return $response->withJson($data,200,JSON_PRETTY_PRINT);
    })->setName("/");

});