Download the PHP package galancev/php-rest-service without Composer
On this page you can find all versions of the php package galancev/php-rest-service. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-rest-service
php-rest-service
Php-Rest-Service is a simple and fast PHP class for RESTful JSON APIs.
Features
- Easy to use syntax
- Regular Expression support
- Error handling through PHP Exceptions
- Parameter validation through PHP function signature
- Can return a summary of all routes or one route through
OPTIONS
method based on PHPDoc (ifOPTIONS
is not overridden) - Support of
GET
,POST
,PUT
,DELETE
,PATCH
,HEAD
andOPTIONS
- Suppress the HTTP status code with ?_suppress_status_code=1 (for clients that have troubles with that)
- Supports ?_method=
httpMethod
as addition to the actual HTTP method. - With auto-generation through PHP's
reflection
Installation
- https://packagist.org/packages/marcj/php-rest-service.
- More information available under https://packagist.org/.
Create a composer.json
:
and run
After the installation, you need to include the vendor/autoload.php
to make the class in your script available.
Requirements
- PHP 5.3 and above.
- PHPUnit to execute the test suite.
- Setup PATH_INFO in mod_rewrite (.htaccess) or other webserver configuration
Example config: apache webserver
nginx webserver
Usage Demo
Way 1. The dirty & fast
Way 2. Auto-Collection
index.php
:
MyRestApi/Admin.php
:
Generates following entry points:
Way 3. Custom rules with controller
index.php
:
MyRestApi/Admin.php
:
Responses
The response body is always a array (JSON per default) containing a status code and the actual data. If a exception has been thrown, it contains the status 500, the exception class name as error and the message as message.
Some examples:
License
Licensed under the MIT License. See the LICENSE file for more details.
Take a look into the code, to get more information about the possibilities. It's well documented.