2017 © Pedro Peláez
 

library fastcgi-zf2-adapter

A PHPFastCGI adapter for the Zend Framework 2

image

okeanrst/fastcgi-zf2-adapter

A PHPFastCGI adapter for the Zend Framework 2

  • Tuesday, May 3, 2016
  • by Okeanrst
  • Repository
  • 2 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

PHPFastCGI Zend Framework 2 Adapter

Experimental!!! First, the application shows 10-fold increase a performance. With the accumulation of the number of requests , the amount of RAM occupied by the application increases , increasing the response time. Tests were conducted with and without the module "zf-commons/zfc-user-doctrine-orm"., (*1)

Usage

Below is an example of FastCGI application based on Zend Framework 2., (*2)

Install ZendSkeletonApplication. Add "PHPFastCGI Zend Framework 2 Adapter" to your application:, (*3)

php composer.phar require okeanrst/fastcgi-zf2-adapter

Add the file below into the project directory:, (*4)

<?php // fcgi.php

chdir(__DIR__);

// Setup autoloading
require_once 'vendor/autoload.php';

use PHPFastCGI\FastCGIDaemon\ApplicationFactory;
use Okeanrst\FastCGIZF2Adapter\AppWrapper;

define('DEV_MOVE', true);

if (DEV_MOVE) {    
    error_reporting(E_ALL & ~E_USER_DEPRECATED);
    ini_set("display_errors", 1);
}

// Create the kernel for the FastCGIDaemon library
$kernel = new AppWrapper(require 'config/application.config.php');

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

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

Supervisor setup

To setup supervisor, open your /path/to/supervisor.d/, create, eg, program_fastcgi_ZF2_1.conf and add the following:, (*5)

[program:fastcgi_zf2_1]
command=php /var/www/FastCGIDaemonZF2/fcgi.php run --port=5001 --host=localhost
autostart=true
autorestart=true
stderr_logfile=/var/log/supervisor/fastcgi_zf2_1.err.log
stdout_logfile=/var/log/supervisor/fastcgi_zf2_1.out.log

Run supervisorctl, execute: reread and then reload., (*6)

Nginx setup

To setup nginx, open your /path/to/nginx/nginx.conf and add an include directive below into http block if it does not already exist:, (*7)

http {
    # ...
    include sites-enabled/*.conf;
}

Create a virtual host configuration file for your project under /path/to/nginx/sites-enabled/zf2-app.localhost.conf it should look something like below:, (*8)

upstream workers {
    server localhost:5001;
    #server localhost:5002;
}

server {
    listen 80;
    server_name fastcgi_zf2;
    root /var/www/FastCGIDaemonZF2/public;

    location / {
        # try to serve file directly, fallback to app.php
        try_files $uri /index.php$is_args$args;
    }

    location ~ ^/index\.php(/|$) {
        fastcgi_pass workers;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;

        fastcgi_param  SCRIPT_FILENAME  $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;

        internal;
    }

    error_log /var/log/nginx/fastcgi_zf2_error.log;
    access_log /var/log/nginx/fastcgi_zf2_access.log;
}

Restart the nginx, now you should be ready to go!, (*9)

The Versions

03/05 2016

dev-master

9999999-dev https://github.com/Okeanrst/FastCGIZF2Adapter

A PHPFastCGI adapter for the Zend Framework 2

  Sources   Download

MIT

The Requires

 

by Avatar Okeanrst

zf2 server daemon fastcgi fast cgi