sinevia/php-library-api

PHP Library API

Installs: 479

Dependents: 2

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 1

Open Issues: 0

pkg:composer/sinevia/php-library-api

v1.2.0 2020-04-05 13:18 UTC

This package is auto-updated.

Last update: 2025-10-06 01:53:47 UTC


README

Tests Gitpod Ready-to-Code

A package to quickly set a PHP webservice

Background

Installation

  • Install via Composer
composer require sinevia/php-library-api

Usage

  1. 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());
  1. Example controller with response:
class PingController{
    function ping(){
        return (new Sinevia\ApiResponse)->success('pong');
    }
}