This package is intended to be used as the starter package for PHP-based NYPL Microservices.
This package adheres to PSR-1, PSR-2, and PSR-4 (using the Composer autoloader).
Via Composer
"require": {
"nypl/microservice-starter": "~0.1"
}
- PHP >=5.5.0
- PHP Extensions
- RESTful HTTP framework (Slim)
- Database PDO library (Slim-PDO)
- Kafka message publishing (Rdkafka)
- Avro serializer (Avro)
- Swagger documentation generator (swagger-php)
- Error logging (Monolog)
- Identity/JWT authentication via NYPL API Gateway (
X-NYPL-Identity
)
See the samples/service
directory to learn how to create an example service.
Create an index.php
with a Service
object and your Slim routes:
$service = new NYPL\Starter\Service();
$service->get("/v0.1/bibs", function (Request $request, Response $response) {
$controller = new Controller\BibController($request, $response);
return $controller->getBibs();
});
Configure your web server to load index.php
on all requests.
See the samples/service-config
directory for sample configuration files for an Apache .htaccess
or Nginx nginx.conf
installation.
Create a Swagger route to generate Swagger specification documentation:
$service->get("/swagger", function (Request $request, Response $response) {
return SwaggerGenerator::generate(__DIR__ . "/src", $response);
});