{"id":19214204,"url":"https://github.com/igniphp/network","last_synced_at":"2025-08-09T15:24:52.103Z","repository":{"id":56989379,"uuid":"144815377","full_name":"igniphp/network","owner":"igniphp","description":"Network utilities: swoole based http server, psr-7 and psr-15 implementations","archived":false,"fork":false,"pushed_at":"2019-12-18T07:23:12.000Z","size":108,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-20T19:36:48.443Z","etag":null,"topics":["framework","php7","psr-15","psr-7","server","swoole"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/igniphp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-15T06:38:02.000Z","updated_at":"2024-12-25T03:34:53.000Z","dependencies_parsed_at":"2022-08-21T12:50:47.769Z","dependency_job_id":null,"html_url":"https://github.com/igniphp/network","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igniphp%2Fnetwork","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igniphp%2Fnetwork/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igniphp%2Fnetwork/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igniphp%2Fnetwork/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/igniphp","download_url":"https://codeload.github.com/igniphp/network/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253831216,"owners_count":21971051,"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":["framework","php7","psr-15","psr-7","server","swoole"],"created_at":"2024-11-09T14:09:28.131Z","updated_at":"2025-05-12T22:21:05.363Z","avatar_url":"https://github.com/igniphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ![Igni logo](https://github.com/igniphp/common/blob/master/logo/full.svg)\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)\n[![Build Status](https://travis-ci.org/igniphp/network.svg?branch=master)](https://travis-ci.org/igniphp/network)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/igniphp/network/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/igniphp/network/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/igniphp/network/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/igniphp/network/?branch=master)\n\n## Requirements\n\n- PHP 7.1 or better\n- Swoole extension is required for network server to work\n\n## Installation\n\nLinux users:\n\n```\npecl install swoole\ncomposer install igniphp/network\n```\n\nMac users with homebrew:\n\n```\nbrew install swoole\ncomposer install igniphp/network\n```\nor:\n```\nbrew install homebrew/php/php71-swoole\ncomposer install igniphp/network\n```\n\n\n## Basic Usage\n\n```php\n\u003c?php\n// Autoloader.\nrequire_once __DIR__ . '/vendor/autoload.php';\n\n// Create server instance.\n$server = new \\Igni\\Network\\Server();\n$server-\u003estart();\n```\n\n### Listeners\n\nIgni http server uses event-driven model that makes it easy to scale and extend.\n\nThere are five type of events available, each of them extends `Igni\\Network\\Server\\Listener` interface:\n\n - `Igni\\Network\\Server\\OnStartListener` fired when server starts\n - `Igni\\Network\\Server\\OnStopListener` fired when server stops\n - `Igni\\Network\\Server\\OnConnectListener` fired when new client connects to the server\n - `Igni\\Network\\Server\\OnCloseListener` fired when connection with the client is closed\n - `Igni\\Network\\Server\\OnRequestListener` fired when new request is dispatched\n \n ```php\n \u003c?php\n // Autoloader.\n require_once __DIR__ . '/vendor/autoload.php';\n \n use Igni\\Network\\Server\\Client;\n use Igni\\Network\\Server\\OnRequestListener;\n use Psr\\Http\\Message\\ServerRequestInterface;\n use Psr\\Http\\Message\\ResponseInterface;\n use Igni\\Network\\Http\\Stream;\n \n // Create server instance.\n $server = new \\Igni\\Network\\Server();\n \n // Each request will retrieve 'Hello' response\n $server-\u003eaddListener(new class implements OnRequestListener {\n     public function onRequest(Client $client, ServerRequestInterface $request, ResponseInterface $response): ResponseInterface {\n        return $response-\u003ewithBody(Stream::fromString(\"Hello world\"));\n     }\n });\n $server-\u003estart();\n ```\n\n### Configuration\n\nServer can be easily configured with `Igni\\Network\\Server\\Configuration` class.\n\nPlease consider following example:\n```php\n\u003c?php\n// Autoloader.\nrequire_once __DIR__ . '/vendor/autoload.php';\n\n// Listen on localhost at port 80.\n$configuration = new \\Igni\\Network\\Server\\Configuration('0.0.0.0', 80);\n\n// Create server instance.\n$server = new \\Igni\\Network\\Server($configuration);\n$server-\u003estart();\n```\n\n##### Enabling ssl support\n```php\n\u003c?php\n// Autoloader.\nrequire_once __DIR__ . '/vendor/autoload.php';\n\n$configuration = new \\Igni\\Network\\Server\\Configuration();\n$configuration-\u003eenableSsl($certFile, $keyFile);\n\n// Create server instance.\n$server = new \\Igni\\Network\\Server($configuration);\n$server-\u003estart();\n```\n\n##### Running server as a daemon\n```php\n\u003c?php\n// Autoloader.\nrequire_once __DIR__ . '/vendor/autoload.php';\n\n$configuration = new \\Igni\\Network\\Server\\Configuration();\n$configuration-\u003eenableDaemon($pidFile);\n\n// Create server instance.\n$server = new \\Igni\\Network\\Server($configuration);\n$server-\u003estart();\n```\nMore examples can be found in the `./examples/` directory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figniphp%2Fnetwork","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figniphp%2Fnetwork","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figniphp%2Fnetwork/lists"}