a lightweight component for implementing a REST API
this library helps you to leverage namespacing to implicitly define API endpoint routes rather than write them by hand; adding new endpoints wont require you to update a routes list
authentication or other operations can be done within the endpoint classes themselves
composer require evalok/php-rest-lightly
example usage: https://github.com/EvaLok/php-rest-lightly/blob/master/demo/public/index.php
configure .htaccess
in demo/public
GET: api/v1/Thing1/555
{
id: 555,
owner: {
*owner: null
},
class: "api\v1\Thing1",
method: "api\v1\Thing1::get",
message: "testing testing 123",
params: [ ]
}
GET: api/v1/Thing1/555/Thing2/777?some=thing
{
id: 777,
owner: {
*id: 555,
*owner: { }
},
class: "api\v1\Thing1\Thing2",
method: "api\v1\Thing1\Thing2::get",
message: "testing testing 123",
params: {
some: "thing"
}
}
api/v1/Restricted/Thing3/888
"403: Forbidden"
- tests
- versioning deprecation demo
- non-json responses
- support for request headers