Nano is a really actual tiny personal home page library that means that you can create very speedy rest APIs.
think it be like abbreviate but if slim is abbreviate, Nano is anorexic.
requirements
strictly requires Hypertext Preprocessor ..
set up
by way of artisan
$ artisan crave midorikocaknano usage
effectively instantiate and include on your app.
use midorikocak\nano\Api; require __DIR__ . supplierautoload.php ; $api = new Api;
i know. it s no longer static.
Defining leisure supplies
Defining rest routes and the usage of wildcards are easy.
$bulletin = welcome to Nano ; $api->get , function exercise $bulletin echo json_encode message => $message; http_response_code; ; $api->submit , characteristic consume $bulletin $enter = arrangementjson_decodefile_get_contents Hypertext Preprocessor:enter , authentic, , JSON_THROW_ON_ERROR; echo json_encode$enter; http_response_code; ; $api->get answer$message , feature $message echo json_encode message => $message; http_response_code; ; fundamental Auth
it be viable cover your routed behind an affidavit layer. currently it expects simple auth, more tips on how to appear quickly.
$authFunction = function $username, $password acknowledgment $username == username && $password == password ; ; $api->authfeature exercise &$api $api->get entriesidentification , function $id echo json_encode id => $id; http_response_code; ; $api->publish entriesidentity , feature $identity answer json_encode id => $id; http_response_code; ; $api->put entriesidentification , characteristic $identification answer json_encode id => $id; http_response_code; ; $api->delete entriesidentity , characteristic $identification http_response_code; ; , $authFunction;
hence the fundamental auth isn t encrypted, using https is exactly counseled.
Testing
that you may look at various your are living API the use of boltcustomer
<?Hypertext Preprocessor acknowledgestrict_types=; namespace midorikocak\nano; utilize GuzzleHttp\customer; consume PHPUnit\Framework\TestCase; class IntegrationTest extends TestCase { public feature testGet: void $client = new customer base_uri => $this->baseUri, http_errors => false, , ; $acknowledgment = $client->request GET , answerhi there ; $this->assertEquals, $response->getStatusCode; $this->assertStringContainsString hiya , cord$response->getBody; motivation
in general educational applications.
exchange log
please see CHANGELOG for greater advice on what has changed currently.
Testing contributing
amuse see contributing and CODE_OF_CONDUCT for particulars.
security
in case you discover any security connected concerns, please email mtkocakgmailm as an alternative of using the issue tracker.