Download .zip |
Info | Documentation | View files (85) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2017-03-21 (2 years ago) | Not enough user ratings | Total: 208 | All time: 8,167 This week: 372 |
Version | License | PHP version | Categories | |||
php-api 0.1.0 | MIT/X Consortium ... | 7 | Web services, PHP 7 |
Description | Author | |
This package can handle API requests with annotated classes. Recommendations Develop Webservice using PHP (Apache) |
|
Create a API for your PHP project in minutes. Simple add an annotation to yours methods and "voilá": it's done.
/
* @Api("my/route")
* No @HttpMethod annotation, accepts all HTTP kinds of request methods
*/
public function myRoute() {
// code
}
/
* @Api("route/with/$var")
* @HttpMethod("PUT") // will accept only PUT requests
*/
public function routeWith($var) {
// code
}
/
* @Api("another/$id/maybe/$var")
* @HttpMethod("GET,POST") // will accept only GET and POST requests
*/
public function routeAnother($id, $var) {
// code
}
As you can see, it uses a Symfony-like router to find the right code to execute. Moreover, it suports the use of patterns so some parts of request can be variables!
Just add a$
inside @Api value to make it act as a method parameter.
This library can be found on Packagist. We endorse that everything will work fine if you install this through composer
.
Add in your composer.json
:
{
"require": {
"ifroariquemes": "dev-master"
}
}
or in your bash
$ composer require ifroariquemes/php-api
From any point, make available the following code to start:
require './vendor/autoload.php';
\PhpApi\PhpApi::start('src'); // your source code directory
If this script is available at http://example.com/api/v1/ (suposing you already have a router working previously) then the API router will understand things starting there: - http://example.com/api/v1/my/route - http://example.com/api/v1/route/with/me - http://example.com/api/v1/another/way/maybe/works
If you are not using a router, but created a new directory to keep our code, remember to enable mod_rewrite
and have a file like this its root to get things done:
AddType application/x-httpd-php .php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]
</IfModule>
<Files "keys.json">
Order Allow,Deny
Deny from all
</Files>
This lib also uses a token system. You can activate it by creating a file named keys.json
at API/project root folder:
{
"SystemName": "token123456"
}
The client will use this token to communicate with the API by adding its value to the key X-API-KEY
within the HTTP request header.
You can also check the docs/ for futher information about the classes and stuff. All codes are well commented so fell free to go deep and help us get this even better.
Files |
File | Role | Description | ||
---|---|---|---|---|
docs (2 files, 9 directories) | ||||
nbproject (2 files, 1 directory) | ||||
src (3 files, 1 directory) | ||||
tests (3 files, 1 directory) | ||||
composer.json | Data | Auxiliary data | ||
composer.lock | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files | / | docs |
Files | / | docs | / | classes |
File | Role | Description |
---|---|---|
PhpApi.Annotations.Api.html | Doc. | Documentation |
PhpApi.Annotations.HttpMethod.html | Doc. | Documentation |
PhpApi.ApiTrait.html | Doc. | Documentation |
PhpApi.PhpApi.html | Doc. | Documentation |
PhpApi.Route.html | Doc. | Documentation |
PhpApi.Token.html | Doc. | Documentation |
Files | / | docs | / | css |
File | Role | Description | ||
---|---|---|---|---|
phpdocumentor-clean-icons (2 files, 1 directory) | ||||
bootstrap-combined.no-icons.min.css | Data | Auxiliary data | ||
font-awesome.min.css | Data | Auxiliary data | ||
jquery.iviewer.css | Data | Auxiliary data | ||
prism.css | Data | Auxiliary data | ||
template.css | Data | Auxiliary data |
Files | / | docs | / | css | / | phpdocumentor-clean-icons |
File | Role | Description | ||
---|---|---|---|---|
fonts (2 files) | ||||
lte-ie7.js | Data | Auxiliary data | ||
style.css | Data | Auxiliary data |
Files | / | docs | / | css | / | phpdocumentor-clean-icons | / | fonts |
File | Role | Description |
---|---|---|
phpdocumentor-clean-icons.dev.svg | Data | Auxiliary data |
phpdocumentor-clean-icons.svg | Data | Auxiliary data |
Files | / | docs | / | files |
File | Role | Description | ||
---|---|---|---|---|
Annotations (2 files) | ||||
Annotations.Api.html | Doc. | Documentation | ||
Annotations.HttpMethod.html | Doc. | Documentation | ||
ApiTrait.html | Doc. | Documentation | ||
ApiTrait.php.txt | Doc. | Documentation | ||
PhpApi.html | Doc. | Documentation | ||
PhpApi.php.txt | Doc. | Documentation | ||
Route.html | Doc. | Documentation | ||
Route.php.txt | Doc. | Documentation | ||
Token.html | Doc. | Documentation | ||
Token.php.txt | Doc. | Documentation |
Files | / | docs | / | files | / | Annotations |
File | Role | Description |
---|---|---|
Api.php.txt | Doc. | Documentation |
HttpMethod.php.txt | Doc. | Documentation |
Files | / | docs | / | images |
File | Role | Description | ||
---|---|---|---|---|
iviewer (8 files) | ||||
apple-touch-icon-114x114.png | Icon | Icon image | ||
apple-touch-icon-72x72.png | Icon | Icon image | ||
apple-touch-icon.png | Icon | Icon image | ||
custom-icons.svg | Data | Auxiliary data | ||
favicon.ico | Data | Auxiliary data | ||
hierarchy-item.png | Icon | Icon image | ||
icon-class-13x13.png | Icon | Icon image | ||
icon-class.svg | Data | Auxiliary data | ||
icon-interface-13x13.png | Icon | Icon image | ||
icon-interface.svg | Data | Auxiliary data | ||
icon-trait-13x13.png | Icon | Icon image | ||
icon-trait.svg | Data | Auxiliary data |
Files | / | docs | / | images | / | iviewer |
File | Role | Description |
---|---|---|
grab.cur | Data | Auxiliary data |
hand.cur | Data | Auxiliary data |
iviewer.rotate_left.png | Icon | Icon image |
iviewer.rotate_right.png | Icon | Icon image |
iviewer.zoom_fit.png | Icon | Icon image |
iviewer.zoom_in.png | Icon | Icon image |
iviewer.zoom_out.png | Icon | Icon image |
iviewer.zoom_zero.png | Icon | Icon image |
Files | / | docs | / | js |
File | Role | Description | ||
---|---|---|---|---|
ui (1 directory) | ||||
bootstrap.min.js | Data | Auxiliary data | ||
html5.js | Data | Auxiliary data | ||
jquery-1.11.0.min.js | Data | Auxiliary data | ||
jquery.dotdotdot-1.5.9.js | Data | Auxiliary data | ||
jquery.dotdotdot-1.5.9.min.js | Data | Auxiliary data | ||
jquery.iviewer.js | Data | Auxiliary data | ||
jquery.iviewer.min.js | Data | Auxiliary data | ||
jquery.mousewheel.js | Data | Auxiliary data | ||
jquery.smooth-scroll.js | Data | Auxiliary data | ||
prism.min.js | Data | Auxiliary data |
Files | / | docs | / | namespaces |
File | Role | Description |
---|---|---|
default.html | Doc. | Documentation |
PhpApi.Annotations.html | Doc. | Documentation |
PhpApi.html | Doc. | Documentation |
Files | / | docs | / | reports |
File | Role | Description |
---|---|---|
deprecated.html | Doc. | Documentation |
errors.html | Doc. | Documentation |
markers.html | Doc. | Documentation |
Files | / | nbproject |
File | Role | Description | ||
---|---|---|---|---|
private (2 files) | ||||
project.properties | Data | Auxiliary data | ||
project.xml | Data | Auxiliary data |
Files | / | nbproject | / | private |
File | Role | Description |
---|---|---|
private.properties | Data | Auxiliary data |
private.xml | Data | Auxiliary data |
Files | / | src |
File | Role | Description | ||
---|---|---|---|---|
Annotations (2 files) | ||||
PhpApi.php | Class | Class source | ||
Route.php | Class | Class source | ||
Token.php | Class | Class source |
Files | / | src | / | Annotations |
File | Role | Description |
---|---|---|
Api.php | Class | Class source |
HttpMethod.php | Class | Class source |
Files | / | tests |
Files | / | tests | / | src |
File | Role | Description |
---|---|---|
Blog.php | Class | Class source |
Contacts.php | Class | Class source |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.