PHP code example of alesanchezr / slim-api-wrapper
1. Go to this page and download the library: Download alesanchezr/slim-api-wrapper 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/ */
alesanchezr / slim-api-wrapper example snippets
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
unction (Request $request, Response $response, array $args) use ($api) {
return $response->withJson(["Hello World"]);
});
$inst->app->get('/hello/private', function (Request $request, Response $response, array $args){
return $response->withJson([
"private" => "object"
]);
})->add($inst->auth()); //here I say I want this endpoint to be private
// adding an internal seed for random private key generation
// this only has to be done once in the entire API
$api->setJWTKey("adSAD43gtterT%rtwre32@");
// pick any username you like for the JWT credentials
$clientId = "alesanchezr";
// generate a key based on that username
$clientKey = $api->generatePrivateKey($clientId);
sh
./vendor/bin/phpunit example/with_tests/tests.php --colors
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.