Download the PHP package igorw/cgi-http-kernel without Composer

On this page you can find all versions of the php package igorw/cgi-http-kernel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cgi-http-kernel

CgiHttpKernel

Adapter from HttpKernelInterface to CGI.

The HttpKernelInterface is a lie

You thought that you need to rewrite your whole application to use HttpFoundation in order to benefit from HttpKernelInterface functional testing?

Well, it turns out that you don't need that at all. Some very smart people came up with this thing called CGI (Common Gateway Interface) which defines an interface between a web server and a web application. It's great because it uses UNIX pipes for communication, which means it is also very easy to pretend to be a web server, and just call the app with any input and env vars on the command line by hand.

In PHP that works by using php-cgi, which fortunately ships with almost every PHP distribution. The most basic way of calling it on the command line is this:

$ php-cgi hello.php

If you want to learn how to do more advanced stuff, read the fucking CGI spec.

So what does this have to do with HttpKernelInterface? CGI and that interface do pretty much the same thing, they abstract communication between web server and app. The kernel interface does this within PHP, CGI does it in a language agnostic way.

The CgiHttpKernel translates between those two interfaces. As a user of the library you interact with it as if it were a true HttpKernelInterface app, but in the background it will actually go ahead and call php-cgi on the command line, parse the output, and return a Response instance.

For example:

$kernel = new CgiHttpKernel(__DIR__.'/../phpBB');

$request = Request::create('/index.php');
$response = $kernel->handle($request);

var_dump($response->getContent());

You can also pass a second argument to the constructor if you want all requests to go through a front controller.

$kernel = new CgiHttpKernel(__DIR__.'/../web', 'app.php');

$request = Request::create('/foo');
$response = $kernel->handle($request);

The real power however comes from using libraries that integrate with the HttpKernelInterface, such as Symfony\Component\HttpKernel\Client.

$kernel = new CgiHttpKernel(__DIR__.'/../phpBB');
$client = new Client($kernel);

$crawler = $client->request('GET', '/index.php');
$this->assertGreaterThan(0, $crawler->filter('.topiclist')->count());

Is it really a lie?

Not really. The CgiHttpKernel only makes sense for functional testing, since it is quite slow. It is slow because it must spawn a new process for every request. This is also the reason why some very smart people came up with FastCGI, which is like CGI but faster.

FastCGI allows the app to start a long-running process that listens on a port and thus does not have the process spawning overhead. In PHP land this is usually managed by PHP-FPM, aka FastCGI Process Manager.

FastCGI is good for production but not really practical for testing since it needs to run in a separate process, listen on a port, requires configuration, etc.

However, there is an FcgiHttpKernel that ports the idea of this project to FastCGI. It may in fact become useful for tests.

When to use CgiHttpKernel?

It is mainly intended to write functional tests for legacy applications. That will hopefully enable you to refactor your legacy code with some confidence of not breaking stuff.

Good luck.

Specifics

Attributes

Request attributes are serialized and provided to the target script through the SYMFONY_ATTRIBUTES env variable. This means that it can get the original attributes as follows:

$attributes = unserialize($_SERVER['SYMFONY_ATTRIBUTES']);

All versions of cgi-http-kernel with dependencies

PHP Build Version
Package Version
Requires symfony/http-kernel Version ~2.1
symfony/process Version ~2.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package igorw/cgi-http-kernel contains the following files

Loading the files please wait ....