pierreco / Slim-api

Example of RESTFul API with table users (PHP MySQL Slimframework). This api use basic authentication

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

##This api use basic authentication Authorization: Basic

Configure database

Copy schema.sql on your database and configure:

$dbhost = "localhost"; $dbuser = "root"; $dbpass = "root"; $dbname = "dataname";

Example cURL commands

// Create a user
$ curl -H "Content-Type: application/json" -X POST -d '{ "lastname": "exmaplelastname", "firstname": "examplefirstname", "email": "pierreddzmcksa@mail.fr", "role": "normal", "password": "pass" }' -u useradmin@mail.fr:password http://yourapiurl/users

// Get a user
$ curl -i -X GET -u useradmin@mail.fr:password http://yourapiurl/users/1

// Update a user
$ curl -H "Content-Type: application/json" -H "Accept: application/json" -X PUT -d '{ "lastname": "pierre", "firstname": "cordier"}' -u useradmin@mail.fr:password http://yourapiurl/users/1

// Delete a user
$ curl -i -X DELETE -u useradmin@mail.fr:password http://yourapiurl/users/1

About

Example of RESTFul API with table users (PHP MySQL Slimframework). This api use basic authentication


Languages

Language:PHP 100.0%