sinevia / php-library-api
PHP Library API
v1.2.0
2020-04-05 13:18 UTC
Requires (Dev)
- phpunit/phpunit: ^8.5
This package is auto-updated.
Last update: 2024-11-05 23:42:20 UTC
README
A package to quickly set a PHP webservice
Background
Installation
- Install via Composer
composer require sinevia/php-library-api
Usage
- The lines bellow create an API service, which serves commands mapped to middleware and class methods:
$commands = [ 'ping' => 'PingController@ping', 'auth/login' => 'AuthController@login', 'auth/register' => 'AuthController@register', 'auth/password-restore' => 'AuthController@passwordRestore', 'account/password-change' => ['MiddlewareController@verifyUser','AccountController@passwordChange'], ]; $api = new Sinevia\ApiService; $api->addCommands($commands); die($api->run());
- Example controller with response:
class PingController{ function ping(){ return (new Sinevia\ApiResponse)->success('pong'); } }