{"id":16674655,"url":"https://github.com/lisachenko/protocol-fcgi","last_synced_at":"2025-04-06T00:08:55.412Z","repository":{"id":18846718,"uuid":"22062760","full_name":"lisachenko/protocol-fcgi","owner":"lisachenko","description":"FastCGI (FCGI) Protocol implementation for PHP","archived":false,"fork":false,"pushed_at":"2023-03-10T04:57:32.000Z","size":61,"stargazers_count":124,"open_issues_count":1,"forks_count":11,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-29T22:11:17.236Z","etag":null,"topics":["fastcgi","fcgi","nginx","php","protocol","protocol-fcgi"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lisachenko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-07-21T12:05:49.000Z","updated_at":"2025-02-25T17:53:02.000Z","dependencies_parsed_at":"2024-06-18T16:50:10.831Z","dependency_job_id":"9ca99b35-a443-4322-a11e-c512d4c80aee","html_url":"https://github.com/lisachenko/protocol-fcgi","commit_stats":{"total_commits":36,"total_committers":5,"mean_commits":7.2,"dds":"0.11111111111111116","last_synced_commit":"783c672be1cda61a2ae4c2370098d083eef27ad0"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lisachenko%2Fprotocol-fcgi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lisachenko%2Fprotocol-fcgi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lisachenko%2Fprotocol-fcgi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lisachenko%2Fprotocol-fcgi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lisachenko","download_url":"https://codeload.github.com/lisachenko/protocol-fcgi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247415967,"owners_count":20935387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastcgi","fcgi","nginx","php","protocol","protocol-fcgi"],"created_at":"2024-10-12T12:43:49.083Z","updated_at":"2025-04-06T00:08:55.394Z","avatar_url":"https://github.com/lisachenko.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Object-oriented implementation of FCGI Protocol for PHP\n---------------------------\n\nFastCGI is an open extension to CGI that provides high performance for all Internet applications without the penalties\nof Web server APIs.\n\nMany modern web-servers such as nginx, apache, lighthttpd, etc are communicating with PHP via FCGI. So, this protocol\nis well known and used in many applications. More detailed information about the protocol is available here here:\nhttp://www.fastcgi.com/devkit/doc/fcgi-spec.html\n\n[![Build Status](https://travis-ci.org/lisachenko/protocol-fcgi.svg)](https://travis-ci.org/lisachenko/protocol-fcgi)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/lisachenko/protocol-fcgi/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/lisachenko/protocol-fcgi/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/lisachenko/protocol-fcgi/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/lisachenko/protocol-fcgi/?branch=master)\n[![Packagist](https://img.shields.io/packagist/v/lisachenko/protocol-fcgi.svg)](https://github.com/lisachenko/protocol-fcgi)\n[![Minimum PHP Version](http://img.shields.io/badge/php-%3E%3D%207.4-8892BF.svg)](https://php.net/)\n[![License](https://img.shields.io/packagist/l/lisachenko/protocol-fcgi.svg)](https://packagist.org/packages/lisachenko/protocol-fcgi)\n\nUsage\n------------\nThis library can be used for implementing both client and server side of FCGI application. For example, nginx can\nconnect to the PHP FCGI daemon, or some library code can connect to the FPM as a FCGI client.\n\nTo install this library, just write\n\n``` bash\n$ composer require lisachenko/protocol-fcgi\n```\n\nAfter that you can use an API to parse/create FCGI requests and responses.\n\nSimple FCGI-client:\n```php\n\u003c?php\n\nuse Lisachenko\\Protocol\\FCGI;\nuse Lisachenko\\Protocol\\FCGI\\FrameParser;\nuse Lisachenko\\Protocol\\FCGI\\Record;\nuse Lisachenko\\Protocol\\FCGI\\Record\\BeginRequest;\nuse Lisachenko\\Protocol\\FCGI\\Record\\Params;\nuse Lisachenko\\Protocol\\FCGI\\Record\\Stdin;\n\ninclude \"vendor/autoload.php\";\n\n// Let's connect to the local php-fpm daemon directly\n$phpSocket = fsockopen('127.0.0.1', 9001, $errorNumber, $errorString);\n$packet    = '';\n\n// Prepare our sequence for querying PHP file\n$packet .= new BeginRequest(FCGI::RESPONDER);;\n$packet .= new Params(['SCRIPT_FILENAME' =\u003e '/var/www/some_file.php']);\n$packet .= new Params();\n$packet .= new Stdin();\n\nfwrite($phpSocket, $packet);\n\n$response = '';\nwhile ($partialData = fread($phpSocket, 4096)) {\n    $response .= $partialData;\n    while (FrameParser::hasFrame($response)) {\n        $record = FrameParser::parseFrame($response);\n        var_dump($record);\n    };\n};\n\nfclose($phpSocket);\n```\n\nTo implement FCGI server, just create a socket and make request-response loop\n\n```php\n\nuse Lisachenko\\Protocol\\FCGI;\nuse Lisachenko\\Protocol\\FCGI\\FrameParser;\nuse Lisachenko\\Protocol\\FCGI\\Record;\nuse Lisachenko\\Protocol\\FCGI\\Record\\BeginRequest;\nuse Lisachenko\\Protocol\\FCGI\\Record\\Params;\nuse Lisachenko\\Protocol\\FCGI\\Record\\Stdin;\n\ninclude \"vendor/autoload.php\";\n\n$server = stream_socket_server(\"tcp://127.0.0.1:9001\" , $errorNumber, $errorString);\n\n// Just take the first one request and process it\n$phpSocket = stream_socket_accept($server);\n\n$response = '';\nwhile ($partialData = fread($phpSocket, 4096)) {\n    $response .= $partialData;\n    while (FrameParser::hasFrame($response)) {\n        $record = FrameParser::parseFrame($response);\n        var_dump($record);\n    };\n};\n\n// We don't respond correctly here, it's a task for your application\n\nfclose($phpSocket);\nfclose($server);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flisachenko%2Fprotocol-fcgi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flisachenko%2Fprotocol-fcgi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flisachenko%2Fprotocol-fcgi/lists"}