Download the PHP package alesanchezr/slim-api-wrapper without Composer
On this page you can find all versions of the php package alesanchezr/slim-api-wrapper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package slim-api-wrapper
Slim On Steroids
Just a small slim wrapper to avoid doing the same things all over again every time I start a new API.
This package is ideal for doing micro-framework architectures where your api is distributed thru several independet servers/developments.
Instalation
If you are going to use Authorization headers you have to allow apache to use HTTP Headers in your .htaccess
:
Creating an API in 1 minute 🧐
Here is an example on how to create a simple api with just one GET /hello
endpoint
📝 Adding a readme to the API
It is good practice to add a README.md file written in markwdown, just call the $api->addReadme()
method to specify the URI you will want users to access yout README.md
💻 Adding more endpoints
The API uses Slim PHP 3.0 on the background, you can add as many endpoints as you like following the Slim documetation.
💡 Here is a list of examples you can use.
🔑 JWT Authentication
-
To create private/authenticated the endpoints just add
->add($inst->auth());
at the end of the edpoint like this: -
Add a secret seed to the API, this will be used as salt for the token generation and you only have to do this step once.
-
Add at least one client to the API, you can pick a username but the secret key has to be generated using the
generatePrivateKey
method. - Now you can make call any request but you have to add the key to the Request
Authorization
header or asaccess_token
on the querystring:
Using QueriString for authentication
Using Authorization
header for authentication
Aditional Info
Run the tests:
All versions of slim-api-wrapper with dependencies
slim/slim Version ^3.0
monolog/monolog Version ^1.24
respect/validation Version ^1.1
phpunit/phpunit Version ^6.5
firebase/php-jwt Version ^5.0