{"id":18766308,"url":"https://github.com/navarr/sockets","last_synced_at":"2025-04-05T09:06:27.590Z","repository":{"id":7606675,"uuid":"8964584","full_name":"navarr/Sockets","owner":"navarr","description":"PHP Socket Classes","archived":false,"fork":false,"pushed_at":"2024-12-30T18:51:15.000Z","size":178,"stargazers_count":50,"open_issues_count":2,"forks_count":23,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-03-29T08:06:08.208Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/navarr.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},"funding":{"github":"navarr"}},"created_at":"2013-03-23T02:14:47.000Z","updated_at":"2024-12-30T18:49:42.000Z","dependencies_parsed_at":"2025-02-03T23:37:40.378Z","dependency_job_id":null,"html_url":"https://github.com/navarr/Sockets","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/navarr%2FSockets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/navarr%2FSockets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/navarr%2FSockets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/navarr%2FSockets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/navarr","download_url":"https://codeload.github.com/navarr/Sockets/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247312077,"owners_count":20918344,"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":[],"created_at":"2024-11-07T18:40:07.800Z","updated_at":"2025-04-05T09:06:27.548Z","avatar_url":"https://github.com/navarr.png","language":"PHP","funding_links":["https://github.com/sponsors/navarr"],"categories":[],"sub_categories":[],"readme":"# Sockets \n\n[![Latest Stable Version](http://poser.pugx.org/navarr/Sockets/v)](https://packagist.org/packages/navarr/Sockets)\n[![Total Downloads](http://poser.pugx.org/navarr/Sockets/downloads)](https://packagist.org/packages/navarr/Sockets)\n[![Latest Unstable Version](http://poser.pugx.org/navarr/Sockets/v/unstable)](https://packagist.org/packages/navarr/Sockets)\n[![License](http://poser.pugx.org/navarr/Sockets/license)](https://packagist.org/packages/navarr/Sockets)  \n![Tests](https://github.com/navarr/Sockets/actions/workflows/commit.yml/badge.svg)\n![Code Coverage](https://codecov.io/gh/navarr/Sockets/branch/main/graph/badge.svg?token=C9DtrzMCrD)\n[![Mutation Score](https://img.shields.io/endpoint?style=flat\u0026url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fnavarr%2FSockets%2Fmain)](https://dashboard.stryker-mutator.io/reports/github.com/navarr/Sockets/main)\n\nSockets is a PHP Library intent on making working with PHP Sockets easier, including the creation and management of a Socket Server.\n\n## Work in Progress\n\nThe code is currently still a work in progress, with the Socket class itself not yet fully complete.  There is a lot I still need to understand about how sockets work both in PHP and probably in C in order to make everything work amazingly.\n\nNot everything is tested yet, and not everything works properly yet.\n\nIt is advised not to seriously use this until I create git tag 1.0.0.  There will be breaking changes before then.\n\n## Usage of SocketServer\n\nUsing SocketServer is supposed to be an easy and trivial task (and the class should be documented enough to understand what it's doing without me).\n\n### Example of an ECHO Server\n\n```php\n\u003c?php\n\nuse Navarr\\Socket\\Socket;\nuse Navarr\\Socket\\Server;\n\nclass EchoServer extends Server\n{\n    const DEFAULT_PORT = 7;\n\n    public function __construct($ip = null, $port = self::DEFAULT_PORT)\n    {\n        parent::__construct($ip, $port);\n        $this-\u003eaddHook(Server::HOOK_CONNECT, array($this, 'onConnect'));\n        $this-\u003eaddHook(Server::HOOK_INPUT, array($this, 'onInput'));\n        $this-\u003eaddHook(Server::HOOK_DISCONNECT, array($this, 'onDisconnect'));\n        $this-\u003erun();\n    }\n\n    public function onConnect(Server $server, Socket $client, $message)\n    {\n        echo 'Connection Established',\"\\n\";\n    }\n\n    public function onInput(Server $server, Socket $client, $message)\n    {\n        echo 'Received \"',$message,'\"',\"\\n\";\n        $client-\u003ewrite($message, strlen($message));\n    }\n\n    public function onDisconnect(Server $server, Socket $client, $message)\n    {\n        echo 'Disconnection',\"\\n\";\n    }\n}\n\n$server = new EchoServer('0.0.0.0');\n\n```\n\n## Development\n\n### Documentation\n\nThis project uses [phpdoc](https://www.phpdoc.org/) to generate documentation. To generate the documentation, you will need to satisfy some dependencies. First, you need to get [graphviz](http://www.graphviz.org/). It is available through most Linux distros, but you can always download it and install it from the site if you aren't on Linux. If you install manually, make sure the binaries are on your PATH somewhere. Next, run the following commands within this directory (assumes you already have [composer](https://getcomposer.org/) installed and available on your path as `composer`).\n\n```bash\ncomposer install # this will install all of the development dependencies for this project\nvendor/bin/phpdoc -d ./src -t ./docs # this will generate the documentation into a docs directory\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnavarr%2Fsockets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnavarr%2Fsockets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnavarr%2Fsockets/lists"}