{"id":22394224,"url":"https://github.com/alexanderomara/php-fpm-cli","last_synced_at":"2025-10-24T05:44:34.534Z","repository":{"id":248054450,"uuid":"827612193","full_name":"AlexanderOMara/php-fpm-cli","owner":"AlexanderOMara","description":"Run PHP scripts through FastCGI from the command line","archived":false,"fork":false,"pushed_at":"2024-07-12T04:54:29.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-01T04:25:58.604Z","etag":null,"topics":["fastcgi","php","php-cli","php-fpm"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlexanderOMara.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2024-07-12T02:37:20.000Z","updated_at":"2024-07-12T04:55:32.000Z","dependencies_parsed_at":"2024-07-12T05:03:01.346Z","dependency_job_id":null,"html_url":"https://github.com/AlexanderOMara/php-fpm-cli","commit_stats":null,"previous_names":["alexanderomara/php-fpm-cli"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderOMara%2Fphp-fpm-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderOMara%2Fphp-fpm-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderOMara%2Fphp-fpm-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderOMara%2Fphp-fpm-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlexanderOMara","download_url":"https://codeload.github.com/AlexanderOMara/php-fpm-cli/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245749796,"owners_count":20666084,"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","php","php-cli","php-fpm"],"created_at":"2024-12-05T05:09:27.579Z","updated_at":"2025-10-24T05:44:29.507Z","avatar_url":"https://github.com/AlexanderOMara.png","language":"PHP","readme":"# php-fpm-cli\n\nRun PHP scripts through FastCGI from the command line\n\n[![Build Status](https://github.com/AlexanderOMara/php-fpm-cli/workflows/main/badge.svg)](https://github.com/AlexanderOMara/php-fpm-cli/actions?query=workflow%3Amain+branch%3Amaster)\n\n# Overview\n\nA PHP CLI script to run PHP scripts through a php-fpm worker that is also a pure-PHP FastCGI request CLI.\n\n# Usage\n\n```\nUsage: php-fpm-cli -c \u003csocket\u003e [options] [script]\n\n  -c, --connect \u003csocket\u003e     Connect to \u003csocket\u003e file or host:port\n  -p, --param \u003ckey\u003e=\u003cvalue\u003e  FCGI request \u003ckey\u003e=\u003cvalue\u003e param\n  -b, --body \u003cbody\u003e          FCGI request STDIN \u003cbody\u003e\n  -d, --data \u003cfile\u003e          FCGI request STDIN body from \u003cfile\u003e\n  -i, --include              FCGI response headers included in output\n  -t, --timeout \u003cduration\u003e   Connect timeout in milliseconds\n  -h, --help                 Display help and exit\n  -v, --version              Display version and exit\n```\n\n# Examples\n\n## Clear opcache\n\nThe cache used by fpm workers and the CLI is separate, so we need to run it inside a php-fpm worker.\n\n```php\n\u003c?php\nprintf(\"%d\\n\", opcache_reset());\n```\n\n```console\n$ php-fpm-cli -c /var/run/php-fpm.sock opcache-reset.php\n1\n```\n\n## GET request with a query string\n\nA query string can be pass by the FCGI parameter.\n\n```php\n\u003c?php\nvar_dump($_GET);\n```\n\n```console\n$ php-fpm-cli -c /var/run/php-fpm.sock -p 'QUERY_STRING=foo=bar\u0026baz=qux' dump-get.php\narray(2) {\n  [\"foo\"]=\u003e\n  string(3) \"bar\"\n  [\"baz\"]=\u003e\n  string(3) \"qux\"\n}\n```\n\n## POST request\n\nA request body can be added which PHP will automatically parse with the correct content type.\n\n```php\n\u003c?php\nvar_dump($_POST);\n```\n\n```console\n$ php-fpm-cli -c /var/run/php-fpm.sock -p 'CONTENT_TYPE=application/x-www-form-urlencoded' -b 'foo=bar\u0026baz=qux' dump-post.php\narray(2) {\n  [\"foo\"]=\u003e\n  string(3) \"bar\"\n  [\"baz\"]=\u003e\n  string(3) \"qux\"\n}\n```\n\n## PUT request\n\nThe default `REQUEST_METHOD` can be overridden.\n\n```php\n\u003c?php\necho md5(file_get_contents('php://input')), \"\\n\";\n```\n\n```\nHello world!\n```\n\n```console\n$ php-fpm-cli -c /var/run/php-fpm.sock -p 'REQUEST_METHOD=PUT' -d file.txt put.php\n86fb269d190d2c85f6e0468ceca42a20\n```\n\n## Headers\n\nSending and printing headers (a non-2XX response produces a non-zero exit code).\n\n```php\n\u003c?php\nhttp_response_code(403);\nheader(\"X-Foo: {$_SERVER['HTTP_X_BAZ']}\");\necho \"Headers above\\n\";\n```\n\n```console\n$ php-fpm-cli --c /var/run/php-fpm.sock -p 'HTTP_X_BAZ=Bar' -i headers.php\nStatus: 403 Forbidden\nX-Powered-By: PHP/X.X.X\nX-Foo: Bar\nContent-type: text/html; charset=UTF-8\n\nHeaders above\n$ echo $?\n1\n```\n\n## Manual request\n\nThe FastCGI request can be manually constructed with just params.\n\n```php\n\u003c?php\necho \"{$_SERVER['REQUEST_METHOD']} {$_SERVER['SCRIPT_FILENAME']}\\n\";\n```\n\n```console\n$ php-fpm-cli -c /var/run/php-fpm.sock -p 'SCRIPT_FILENAME=/path/to/script.php' -p 'REQUEST_METHOD=GET'\nGET /path/to/script.php\n```\n\n# Compatibility\n\nDesigned to be backwards compatible from PHP 5.0.0 onward.\n\nCompatibility with PHP versions before 5.5.36 is not guaranteed for lack of compatible docker images to test with.\n\nIf you have compatiability issues, bug reports and patches are welcome!\n\n# License\n\nCopyright (c) 2024 Alexander O'Mara\n\nLicensed under the Mozilla Public License, v. 2.0.\n\nIf this license does not work for you, feel free to contact me.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexanderomara%2Fphp-fpm-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexanderomara%2Fphp-fpm-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexanderomara%2Fphp-fpm-cli/lists"}