{"id":19854727,"url":"https://github.com/phwoolcon/php-sapihack","last_synced_at":"2026-06-09T02:01:59.127Z","repository":{"id":93559806,"uuid":"101291264","full_name":"phwoolcon/php-sapihack","owner":"phwoolcon","description":"PHP Extension: SAPI Hack","archived":false,"fork":false,"pushed_at":"2017-08-25T12:23:06.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T23:38:33.780Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phwoolcon.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":"2017-08-24T12:13:23.000Z","updated_at":"2023-01-16T08:29:55.000Z","dependencies_parsed_at":"2023-03-13T17:17:32.654Z","dependency_job_id":null,"html_url":"https://github.com/phwoolcon/php-sapihack","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/phwoolcon/php-sapihack","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phwoolcon%2Fphp-sapihack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phwoolcon%2Fphp-sapihack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phwoolcon%2Fphp-sapihack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phwoolcon%2Fphp-sapihack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phwoolcon","download_url":"https://codeload.github.com/phwoolcon/php-sapihack/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phwoolcon%2Fphp-sapihack/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34088013,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-12T14:10:14.052Z","updated_at":"2026-06-09T02:01:59.094Z","avatar_url":"https://github.com/phwoolcon.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# php-sapihack\n\nPHP Extension: SAPI Hack\n## Use case\nHeaders are not used completely in CLI mode, but `headers_sent` is always set to `1`\nif any content is echoed on the screen, then we get unexpected annoying error with\nmessage `headers already sent`\n\nUse this extension to avoid such errors and keep running smoothly in CLI mode, especially\nin PHP 7.2, some `session_` functions behaves different than older versions:\n\n* `session_name()`\n* `session_set_save_handler()`\n* `session_save_path()`\n\nThis check (`headers already sent`) is necessary in CGI mode, but this should not happen\nin CLI mode, for example, when we running `swoole` or `phpunit`.\n\n## Installation\n```bash\ngit clone git@github.com:phwoolcon/php-sapihack.git\nphpize\n./configure --enable-sapihack\nmake\nsudo make install\necho 'extension = sapihack.so' \u003e /etc/php/7.2/mods-available/sapihack.ini\nsudo ln -s ../../mods-available/sapihack.ini /etc/php/7.2/fpm/conf.d/20-sapihack.ini\nsudo ln -s ../../mods-available/sapihack.ini /etc/php/7.2/cli/conf.d/20-sapihack.ini\nservice php7.2-fpm restart\n```\n\n## Documentation\n\n### Constants\n`SAPIHACK_VERSION`\n\n`SAPIHACK_VERSION_ID`\n\n### Functions\n#### sapihack_reset_headers_sent()\n**WARNING** Only use this function in CLI mode.\n\n```php\n\u003c?php\necho 'Something has been output to STDOUT, but this is not HTTP response in CLI mode';\necho 'But `sapi_globals.headers_sent` has been set to 1';\necho 'Then you will not be able to use `session_` functions in php 7.2';\necho 'Call `sapihack_reset_headers_sent()` to help you';\n\n// Use SAPIHACK_VERSION_ID to detect extension availablity\ndefined('SAPIHACK_VERSION_ID') and sapihack_reset_headers_sent();\nsession_name('my_app');\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphwoolcon%2Fphp-sapihack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphwoolcon%2Fphp-sapihack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphwoolcon%2Fphp-sapihack/lists"}