2017 © Pedro Peláez
 

library php-api

A neat little framework for creating PHP APIs

image

matthiasmullie/php-api

A neat little framework for creating PHP APIs

  • Sunday, December 10, 2017
  • by matthiasmullie
  • Repository
  • 1 Watchers
  • 2 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

php-api

Build status Code coverage Code quality Latest version Downloads total License, (*1)

Example usage

Setting up is really simple., (*2)

You'll need a routing config:, (*3)

test:
    method: [GET, POST]
    path: /
    handler: MatthiasMullie\ApiExample\ExampleController

A few lines to bootstrap, in a file where all of your requests end up:, (*4)

$routes = new MatthiasMullie\Api\Routes\Providers\YamlRouteProvider(__DIR__.'/../config/routes.yml');
$handler = new MatthiasMullie\Api\RequestHandler($routes);
$response = $handler->route(GuzzleHttp\Psr7\ServerRequest::fromGlobals());
$handler->output($response);

And a controller:, (*5)

namespace MatthiasMullie\ApiExample;

class ExampleController implements MatthiasMullie\Api\Controllers\JsonController
{
    public function __invoke(Psr\Http\Message\ServerRequestInterface $request, ResponseInterface $response, array $args)
    {
        // hey there, I can process your request!

        return [
            'status_code' => 200,
            'hello' => 'world',
        ];
    }
}

Or take a look at this exact same example in a clean repo, at matthiasmullie/php-api-example., (*6)

Installation

Simply add a dependency on matthiasmullie/php-api to your composer.json file if you use Composer to manage the dependencies of your project:, (*7)

composer require matthiasmullie/php-api

Although it's recommended to use Composer, you can actually include these files anyway you want., (*8)

License

php-api is MIT licensed., (*9)

The Versions

10/12 2017

dev-master

9999999-dev https://github.com/matthiasmullie/php-api

A neat little framework for creating PHP APIs

  Sources   Download

MIT

The Requires

 

The Development Requires

api framework php skeleton

08/12 2017