{"id":16184408,"url":"https://github.com/cbl/php-pusher","last_synced_at":"2025-04-07T12:46:30.788Z","repository":{"id":62500225,"uuid":"94789534","full_name":"cbl/php-pusher","owner":"cbl","description":"Php Package to create a Simple Websocket Pusher.","archived":false,"fork":false,"pushed_at":"2017-07-15T13:54:54.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-04T04:11:19.872Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cbl.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":"2017-06-19T15:04:18.000Z","updated_at":"2017-06-19T15:19:39.000Z","dependencies_parsed_at":"2022-11-02T11:47:18.122Z","dependency_job_id":null,"html_url":"https://github.com/cbl/php-pusher","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbl%2Fphp-pusher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbl%2Fphp-pusher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbl%2Fphp-pusher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbl%2Fphp-pusher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cbl","download_url":"https://codeload.github.com/cbl/php-pusher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247656104,"owners_count":20974299,"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-10-10T07:10:06.980Z","updated_at":"2025-04-07T12:46:30.755Z","avatar_url":"https://github.com/cbl.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Pusher\n\nA PHP Websocket framework that is build on [Ratchet](http://socketo.me/) to create a powerfull Websocket Server,\nthat pushes Data to your Clients to keep them up to Date.\n\n## Requirements\n\nShell access is required and root access is recommended.\n\n## Getting Started\n\nTo install the framework, run: ```composer require cbl/php-pusher```\n\n## Code Example\n\nServer:\n\n```php\n\u003c?php\nuse PhpPusher\\Server;\n\nrequire_once __DIR__ . \"/../../vendor/autoload.php\";\n\nclass PusherServer extends Server\n{\n    public $key     = 'Password';\n    public $port    = 8080;\n\n    public function authLogin($client) {\n        $cookies = $client-\u003eWebSocket-\u003erequest-\u003egetCookies();\n        // return false if the client has no session\n        if(!isset($cookies['session']))\n            return false;\n        $session = $cookies['session'];\n        if(!$session)\n            return false;\n        // Return the user id\n        return 5;\n        //return getUserIdBySession(urldecode($session));\n    }\n\n    public function authAdmin($client) {\n        $admin_ids = [1,5,9];\n        if(in_array($client-\u003elogin, $admin_ids))\n            return true;\n        return false;\n    }\n}\n\n// config\n$config = [\n    // Store multiple datasets in cache.\n    'list' =\u003e [\n        'chat_messages' =\u003e [\n            'save_auth' =\u003e true\n        ],\n        'wallet' =\u003e [\n            'cache' =\u003e false,\n            'auth'  =\u003e ['login' =\u003e 'only']\n        ]\n    ],\n    // Store only one dataset in cache\n    'dict' =\u003e [\n        'player' =\u003e [\n            'auth' =\u003e ['login' =\u003e true]\n        ]\n    ],\n    'specials' =\u003e [\n        'online_counter' =\u003e true\n    ]\n];\n// Create Server\n$server = new PusherServer();\n$server-\u003esetConfig($config);\n$server-\u003erun();\n```\n\nClient:\n\n```php\n\u003c?php\nuse PhpPusher\\Client;\n\nrequire_once __DIR__ . \"/../../vendor/autoload.php\";\n\n$key    = 'Password';\n$client = new Client($key);\n\n// Set a receiver id\n$receiver = 5;\n// Send a Chat Message\n$client-\u003esend('chat_message', 'Hi!', $receiver);\n// Send wallet amount only to the receiver\n$client-\u003esend('wallet', 100, $receiver);\n// Start a timer\n$client-\u003estartTimer('game_timer', 30, true);\n// Publish game after timer\n$client-\u003esend('game', [\n    'data' =\u003e 'Some Data.'\n]);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcbl%2Fphp-pusher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcbl%2Fphp-pusher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcbl%2Fphp-pusher/lists"}