Maurits van der Schee 7d8c2b5e9a Restructured files | 9 lat temu | |
---|---|---|
.gitignore | 9 lat temu | |
.htaccess | 9 lat temu | |
README.md | 9 lat temu | |
config.php.dist | 9 lat temu | |
index.php | 9 lat temu | |
list.php | 9 lat temu | |
read.php | 9 lat temu |
Simple PHP script that adds a very basic API to a MySQL database
$config = array(
"hostname"=>"localhost",
"username"=>"root",
"password"=>"root",
"database"=>"blog",
"read_whitelist"=>false,
"read_blacklist"=>array("users"),
"list_whitelist"=>false,
"list_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?page=1
GET http://localhost/api/categories?page=1:50
{"categories":{"pages":"1","columns":["id","name"],"records":[["1","Internet"],["3","Web development"]]}}
GET http://localhost/api/categories?filter=name:Inter
GET http://localhost/api/categories?filter=name:Internet&match=exact
GET http://localhost/api/categories?filter=id:1&match=upto
GET http://localhost/api/categories?filter=id:2&match=lower
{"categories":{"pages":"1","columns":["id","name"],"records":[["1","Internet"]]}}
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