2017 © Pedro Peláez
 

library expressive-adapter

A PHPFastCGI adapter for the Zend Expressive framework

image

phpfastcgi/expressive-adapter

A PHPFastCGI adapter for the Zend Expressive framework

  • Wednesday, January 13, 2016
  • by AndrewCarterUK
  • Repository
  • 6 Watchers
  • 28 Stars
  • 302 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 2 Versions
  • 1 % Grown

The README.md

PHPFastCGI Zend Expressive Adapter

Latest Stable Version Build Status Coverage Status Scrutinizer Code Quality Total Downloads, (*1)

A PHP package that allows Zend Expressive applications to reduce overheads by exposing their Request-Response structure to a FastCGI daemon., (*2)

Visit the project website., (*3)

Introduction

Using this package, Zend Expressive applications can stay alive between HTTP requests whilst operating behind the protection of a FastCGI enabled web server., (*4)

Current Status

This project is currently in early stages of development and not considered stable. Importantly, this library currently lacks support for uploaded files., (*5)

Contributions and suggestions are welcome., (*6)

Installing

composer require "phpfastcgi/expressive-adapter:^0.1"

Usage

<?php // command.php

// Include the composer autoloader
require_once dirname(__FILE__) . '/../vendor/autoload.php';

use PHPFastCGI\FastCGIDaemon\ApplicationFactory;
use PHPFastCGI\Adapter\Expressive\ApplicationWrapper;
use Zend\Expressive\AppFactory;

// Create your Expressive app
$app = AppFactory::create();
$app->get('/', function ($request, $response, $next) {
    $response->getBody()->write('Hello, World!');
    return $response;
});

// Create the kernel for the FastCGIDaemon library (from the Expressive app)
$kernel = new ApplicationWrapper($app);

// Create the symfony console application
$consoleApplication = (new ApplicationFactory)->createApplication($kernel);

// Run the symfony console application
$consoleApplication->run();

If you wish to configure your FastCGI application to work with the apache web server, you can use the apache FastCGI module to process manage your application., (*7)

This can be done by creating a FastCGI script that launches your application and inserting a FastCgiServer directive into your virtual host configuration., (*8)

#!/bin/bash
php /path/to/command.php run
FastCgiServer /path/to/web/root/script.fcgi

By default, the daemon will listen on FCGI_LISTENSOCK_FILENO, but it can also be configured to listen on a TCP address. For example:, (*9)

php /path/to/command.php run --port=5000 --host=localhost

If you are using a web server such as NGINX, you will need to use a process manager to monitor and run your application., (*10)

AstroSplash: An Example

The AstroSplash website currently runs using this adapter. If you are looking for an example integration, you may find the source code repository helpful., (*11)

The two important files:, (*12)

This PHP script creates and runs a FastCGI application using the Zend Expressive application object., (*13)

As NGINX is used, supervisord was chosen to manage instances of the FastCGI application. This would not be necessary using Apache as it has a process manager built into the FastCGI module. This configuration file provides instructions for supervising the FastCGI application instances., (*14)

NGINX Configuration

Below is an example of the changes that were made to the NGINX configuration file for AstroSplash:, (*15)

upstream workers {
    server localhost:5000;
    server localhost:5001;
    server localhost:5002;
    server localhost:5003;
}

server {
    # ... 

    location # ... {
        include         /etc/nginx/fastcgi_params;
        fastcgi_pass    workers;
        # ...
    }

    # ...
}

The Versions

13/01 2016

dev-master

9999999-dev

A PHPFastCGI adapter for the Zend Expressive framework

  Sources   Download

MIT

The Requires

 

The Development Requires

server zend daemon expressive fastcgi fast cgi

10/01 2016

v0.1.0

0.1.0.0

A PHPFastCGI adapter for the Zend Expressive framework

  Sources   Download

MIT

The Requires

 

The Development Requires

server zend daemon expressive fastcgi fast cgi