Git Product home page Git Product logo

php-microservice-starter's Introduction

NYPL PHP Microservice Starter

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).

Installation

Via Composer

"require": {
    "nypl/microservice-starter": "~0.1"
}

Requirements

  • PHP >=5.5.0
  • PHP Extensions

Features

  • 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)

Usage

HTTP/API Server

See the samples/service directory to learn how to create an example service.

Basic Example

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.

Swagger Documentation Generator

Create a Swagger route to generate Swagger specification documentation:

$service->get("/swagger", function (Request $request, Response $response) {
    return SwaggerGenerator::generate(__DIR__ . "/src", $response);
});

php-microservice-starter's People

Contributors

gkallenberg avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.