A package to quickly set a PHP webservice
- Install via Composer
composer require sinevia/php-library-api
- 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');
}
}