Skip to content

Commit

Permalink
Added usage documentation to README
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewCarterUK committed Jul 3, 2015
1 parent 1e66ef1 commit 7d812b8
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions README.md
Expand Up @@ -16,6 +16,58 @@ The daemon requires a handler to be defined that accepts PSR-7 requests and retu

The [Speedfony Bundle](https://github.com/PHPFastCGI/SpeedfonyBundle) integrates this daemon with the symfony2 framework.

## Usage

Below is an example of a simple 'Hello, World!' FastCGI application in PHP.

```php
<?php // application.php

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

use PHPFastCGI\FastCGIDaemon\Command\DaemonRunCommand;
use PHPFastCGI\FastCGIDaemon\DaemonFactory;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Component\Console\Application;
use Zend\Diactoros\Response\HtmlResponse;

// Create the dependencies for the DaemonRunCommand

// Dependency 1: The daemon factory
$daemonFactory = new DaemonFactory();

// Dependency 2: A simple kernel. This is the core of your application
$kernel = function (ServerRequestInterface $request) {
return new HtmlResponse('<h1>Hello, World!</h1>');
};

// Create an instance of DaemonRunCommand using the daemon factory and the kernel
$command = new DaemonRunCommand('run', 'Run a FastCGI daemon', $daemonFactory, $kernel);

// Create a symfony console application and add the command
$consoleApplication = new Application();
$consoleApplication->add($command);

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

This can be done by creating an FCGI script that launches your application and inserting a FastCgiServer directive into your virtual host configuration.

```sh
#!/bin/bash
php /path/to/application.php run
```

```
FastCgiServer /path/to/web/root/index.fcgi
```

If you are using a web server such as nginx, you will need to use a process manager to monitor and run your application.

## Current Status

This daemon is currently in early development stages and not considered stable. A stable release is expected by September 2015.
Expand Down

0 comments on commit 7d812b8

Please sign in to comment.