|
| 1 | +# PHP FastCGI Client |
| 2 | + |
| 3 | +[](https://packagist.org/packages/adoy/fastcgi-client) |
| 4 | +[](https://packagist.org/packages/adoy/fastcgi-client) |
| 5 | +[](https://packagist.org/packages/adoy/fastcgi-client) |
| 6 | + |
| 7 | +*PHP FastCGI Client* is a lightweight single file **FastCGI** client for PHP. |
| 8 | + |
| 9 | +## How can I use it ? |
| 10 | + |
| 11 | +```php |
| 12 | +<?php |
| 13 | + |
| 14 | +require 'vendor/autoload.php'; |
| 15 | + |
| 16 | +use Adoy\FastCGI\Client; |
| 17 | + |
| 18 | +// Existing socket, such as Lighttpd with mod_fastcgi: |
| 19 | +$client = new Client('unix:///path/to/php/socket', -1); |
| 20 | + |
| 21 | +// Fastcgi server, such as PHP-FPM: |
| 22 | +$client = new Client('localhost', '9000'); |
| 23 | +$content = 'key=value'; |
| 24 | +echo $client->request( |
| 25 | + array( |
| 26 | + 'GATEWAY_INTERFACE' => 'FastCGI/1.0', |
| 27 | + 'REQUEST_METHOD' => 'POST', |
| 28 | + 'SCRIPT_FILENAME' => 'test.php', |
| 29 | + 'SERVER_SOFTWARE' => 'php/fcgiclient', |
| 30 | + 'REMOTE_ADDR' => '127.0.0.1', |
| 31 | + 'REMOTE_PORT' => '9985', |
| 32 | + 'SERVER_ADDR' => '127.0.0.1', |
| 33 | + 'SERVER_PORT' => '80', |
| 34 | + 'SERVER_NAME' => 'mag-tured', |
| 35 | + 'SERVER_PROTOCOL' => 'HTTP/1.1', |
| 36 | + 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', |
| 37 | + 'CONTENT_LENGTH' => strlen($content) |
| 38 | + ), |
| 39 | + $content |
| 40 | +); |
| 41 | +``` |
| 42 | + |
| 43 | +## Command line tool |
| 44 | + |
| 45 | +Run a call through a network socket: |
| 46 | + |
| 47 | +``` |
| 48 | +./fcgiget.php localhost:9000/status |
| 49 | +``` |
| 50 | + |
| 51 | +Run a call through a Unix Domain Socket |
| 52 | + |
| 53 | +``` |
| 54 | +./fcgiget.php unix:/var/run/php-fpm/web.sock/status |
| 55 | +``` |
| 56 | + |
| 57 | +> **Note:** This command line tool is provided for debuging purpose. |
| 58 | +
|
| 59 | +## Authors |
| 60 | + |
| 61 | +* _**[Pierrick Charron](https://github.com/adoy)** (pierrick@php.net) - Initial work_ |
| 62 | +* _**[Remi Collet](https://github.com/remicollet)**_ |
| 63 | + |
| 64 | +## License |
| 65 | + |
| 66 | +This project is licensed under the MIT License - for the full copyright and license information, please view the [LICENSE](LICENSE) file that was distributed with this source code. |
| 67 | + |
| 68 | +--- |
| 69 | +_Copyrights 2010-2019 Pierrick Charron Inc. All rights reserved._ |
0 commit comments