Maurits van der Schee 9e070ff0ca Improve CRUD naming | 9 years ago | |
---|---|---|
.gitignore | 9 years ago | |
.htaccess | 9 years ago | |
README.md | 9 years ago | |
config.php.dist | 9 years ago | |
list.php | 9 years ago | |
read.php | 9 years ago |
Simple PHP script that adds a very basic API to a MySQL database
$config = array(
"hostname"=>"localhost",
"username"=>"root",
"password"=>"root",
"database"=>"blog",
"whitelist"=>false,
"blacklist"=>array("users"),
);
GET http://localhost/api/categories
GET http://localhost/api/categories,users
GET http://localhost/api/cate*
GET http://localhost/api/cate*,user*
{"categories":{"columns":["id","name"],"records":[["1","Internet"],["3","Web development"]]}}
GET http://localhost/api/categories/1
{"id":"1","name":"Internet"}
Put the files in a folder named “api” and edit config.php.dist and rename it to config.php. Let Apache serve the parent folder or configure the .htaccess RewriteBase to match the exposed part of the path.
MIT