Skip to content

EvaLok/php-rest-lightly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-rest-lightly

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

installation instructions

composer require evalok/php-rest-lightly

example usage: https://github.com/EvaLok/php-rest-lightly/blob/master/demo/public/index.php

demo

configure .htaccess in demo/public

Examples

  • 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"

TODO

  • tests
  • versioning deprecation demo
  • non-json responses
  • support for request headers

About

a lightweight component for implementing a REST API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages