Skip to content

Commit

Permalink
Documented changes in application-factory branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Carter committed Aug 14, 2015
1 parent cc365ab commit 6a8c657
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions README.md
Expand Up @@ -27,31 +27,20 @@ Below is an example of a simple 'Hello, World!' FastCGI application in PHP.
// Include the composer autoloader
require_once dirname(__FILE__) . '/../vendor/autoload.php';

use PHPFastCGI\FastCGIDaemon\Command\DaemonRunCommand;
use PHPFastCGI\FastCGIDaemon\DaemonFactory;
use PHPFastCGI\FastCGIDaemon\ApplicationFactory;
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
// 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);
// Create your Symfony console application using the factory
$application = (new ApplicationFactory)->createApplication($kernel);

// Run the symfony console application
$consoleApplication->run();
// Run the Symfony console application
$application->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.
Expand Down

0 comments on commit 6a8c657

Please sign in to comment.