PHP code example of tomlerendu / microapi

1. Go to this page and download the library: Download tomlerendu/microapi 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/ */

    

tomlerendu / microapi example snippets


return function($router)
{

    $router->get([
        'route' => '/name/(name)',
        'class' => 'Example@getName',
        'functionExample@postName',
    ]);

};

$router->get([
    'route' => '/user/(id)',
    'function' => 'user@details',
    'tPathWildcard('id'));
        return count($user) === 1;
    }
]);

function myController($request, $response, $database)
{
    $id = $request->getParam('id');
    $results = $database->select('SELECT * FROM Table WHERE id = ?', $id);

    $response->make($results);
}