{"id":13699988,"url":"https://github.com/utopia-php/swoole","last_synced_at":"2025-04-06T07:14:05.967Z","repository":{"id":44545617,"uuid":"287632215","full_name":"utopia-php/swoole","owner":"utopia-php","description":"An extension for Utopia Framework to work with PHP Swoole as a PHP FPM alternative","archived":false,"fork":false,"pushed_at":"2025-03-26T10:09:17.000Z","size":533,"stargazers_count":18,"open_issues_count":2,"forks_count":11,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-26T11:25:02.746Z","etag":null,"topics":["hacktoberfest","php","swoole","utopia-framework"],"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/utopia-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2020-08-14T22:02:50.000Z","updated_at":"2025-03-26T10:09:10.000Z","dependencies_parsed_at":"2025-03-26T11:22:58.432Z","dependency_job_id":"e79b0420-7481-44b2-820a-76af5338c08d","html_url":"https://github.com/utopia-php/swoole","commit_stats":{"total_commits":88,"total_committers":14,"mean_commits":6.285714285714286,"dds":0.7159090909090908,"last_synced_commit":"2949a1bd93f5c772fc7de974e6b9da01106c704a"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fswoole","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fswoole/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fswoole/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fswoole/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/utopia-php","download_url":"https://codeload.github.com/utopia-php/swoole/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247445680,"owners_count":20939961,"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":["hacktoberfest","php","swoole","utopia-framework"],"created_at":"2024-08-02T20:00:46.814Z","updated_at":"2025-04-06T07:14:05.949Z","avatar_url":"https://github.com/utopia-php.png","language":"PHP","funding_links":[],"categories":["Framework Integration"],"sub_categories":[],"readme":"# Utopia Swoole\n\n[![Build Status](https://travis-ci.com/utopia-php/swoole.svg?branch=master)](https://travis-ci.com/utopia-php/swoole)\n[![Discord](https://img.shields.io/discord/564160730845151244?label=discord)](https://appwrite.io/discord)\n![Total Downloads](https://img.shields.io/packagist/dt/utopia-php/swoole.svg)\n\nAn extension for Utopia Framework to work with [PHP Swoole](https://github.com/swoole/swoole-src) as a PHP FPM alternative. This library extends the default Utopia Request \u0026 Response classes with ones that can interact with the Swoole server. This library is aiming to be as simple and easy to learn and use. This library is maintained by the [Appwrite team](https://appwrite.io).\n\nThis library is part of the [Utopia Framework](https://github.com/utopia-php/framework) project. Your PHP installation should be compiled with the [PHP Swoole](https://github.com/swoole/swoole-src) extension for this library to work with Utopia PHP.\n\n## Getting Started\n\nInstall using composer:\n```bash\ncomposer require utopia-php/swoole\n```\n\n```php\n\u003c?php\n\nif (file_exists(__DIR__.'/../vendor/autoload.php')) {\n    require __DIR__.'/../vendor/autoload.php';\n}\n\nuse Utopia\\App;\nuse Utopia\\Swoole\\Request;\nuse Utopia\\Swoole\\Response;\nuse Utopia\\Swoole\\Files;\nuse Swoole\\Http\\Server;\nuse Swoole\\Http\\Request as SwooleRequest;\nuse Swoole\\Http\\Response as SwooleResponse;\n\n$http = new Server(\"0.0.0.0\", 80);\n\nFiles::load(__DIR__ . '/../public'); // Static files location\n\n$http-\u003eon('request', function (SwooleRequest $swooleRequest, SwooleResponse $swooleResponse) {\n    $request = new Request($swooleRequest);\n    $response = new Response($swooleResponse);\n\n    if(Files::isFileLoaded($request-\u003egetURI())) { // output static files with cache headers\n        $time = (60 * 60 * 24 * 365 * 2); // 45 days cache\n\n        $response\n            -\u003esetContentType(Files::getFileMimeType($request-\u003egetURI()))\n            -\u003eaddHeader('Cache-Control', 'public, max-age='.$time)\n            -\u003eaddHeader('Expires', \\date('D, d M Y H:i:s', \\time() + $time).' GMT') // 45 days cache\n            -\u003esend(Files::getFileContents($request-\u003egetURI()))\n        ;\n\n        return;\n    }\n\n    $app = new App('Asia/Tel_Aviv');\n    \n    try {\n        $app-\u003erun($request, $response);\n    } catch (\\Throwable $th) {\n        $swooleResponse-\u003eend('500: Server Error');\n    }\n});\n\n$http-\u003estart();\n\n```\n\n## System Requirements\n\nUtopia Framework requires PHP 8.0 or later. We recommend using the latest PHP version whenever possible.\n\n## Copyright and license\n\nThe MIT License (MIT) [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futopia-php%2Fswoole","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Futopia-php%2Fswoole","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futopia-php%2Fswoole/lists"}