{"id":19696256,"url":"https://github.com/axiosleo/tpr-workerman","last_synced_at":"2025-02-27T11:38:32.738Z","repository":{"id":62490425,"uuid":"299963377","full_name":"AxiosLeo/tpr-workerman","owner":"AxiosLeo","description":"Use TPR framework with workerman","archived":false,"fork":false,"pushed_at":"2021-05-25T15:21:43.000Z","size":30,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-10T09:43:24.967Z","etag":null,"topics":["tpr-framework","workerman"],"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/AxiosLeo.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}},"created_at":"2020-09-30T15:22:27.000Z","updated_at":"2021-05-30T07:06:48.000Z","dependencies_parsed_at":"2022-11-02T11:03:04.283Z","dependency_job_id":null,"html_url":"https://github.com/AxiosLeo/tpr-workerman","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AxiosLeo%2Ftpr-workerman","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AxiosLeo%2Ftpr-workerman/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AxiosLeo%2Ftpr-workerman/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AxiosLeo%2Ftpr-workerman/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AxiosLeo","download_url":"https://codeload.github.com/AxiosLeo/tpr-workerman/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241007782,"owners_count":19893055,"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":["tpr-framework","workerman"],"created_at":"2024-11-11T19:34:25.846Z","updated_at":"2025-02-27T11:38:32.689Z","avatar_url":"https://github.com/AxiosLeo.png","language":"PHP","readme":"# Use TPR framework with workerman\n\n## Require\n\n- PHP \u003e= 7.4\n- [workerman](https://github.com/walkor/workerman) \u003e= 4.0\n\n## Install\n\n```bash\ncomposer require axios/tpr-workerman\n```\n\n## Usage\n\n\u003e [workerman.php](https://github.com/AxiosCros/tpr-app/blob/master/public/workerman.php)\n\n- Simple\n\n```php\n\u003c?php\nnamespace demo;\n\nrequire_once __DIR__ . '/vendor/autoload.php';\n\nuse tpr\\App;\nuse tpr\\server\\WorkermanServer;\n\nApp::registerServer('workerman', WorkermanServer::class);\n\nApp::drive('workerman')-\u003erun();\n```\n\n- Complete Example\n\n```php\n\u003c?php\n\ndeclare(strict_types = 1);\n\nnamespace demo;\n\nrequire_once __DIR__ . '/vendor/autoload.php';\n\nuse tpr\\App;\nuse tpr\\Event;\nuse tpr\\Path;\nuse tpr\\server\\WorkermanServer;\nuse Workerman\\Worker;\n\nPath::configurate([\n    'root' =\u003e __DIR__,\n]);\n\nApp::debugMode(false);\n\nApp::registerServer('workerman', WorkermanServer::class);\n\nApp::drive('workerman'); // initialize App before initialize Event\n\nEvent::on('worker_init', function (Worker $worker) {\n    // handle worker object in here\n});\n\nApp::workerman()\n    -\u003econfig([\n        'namespace'       =\u003e 'app',           // app base namespace, ### this is required ###\n        'lang'            =\u003e 'zh-cn',         // default language set name\n        'cache_time'      =\u003e 60,              // global cache time for config\u0026route data\n        'force_route'     =\u003e false,           // forces use routing\n        'remove_headers'  =\u003e [],              // remove some header before send response\n        // for ServerHandler custom config.\n        'server_options'  =\u003e [\n            'protocol' =\u003e 'http', // support websocket | http | tcp | other custom protocol\n            'host'     =\u003e '0.0.0.0',\n            'port'     =\u003e 2346,\n            'worker'   =\u003e 4,      // the number of worker process\n            'context'  =\u003e [],     // for enable ssl : https://github.com/walkor/Workerman#enable-ssl\n            'options'  =\u003e [],     // properties of worker. https://github.com/walkor/workerman-manual/blob/master/english/src/worker-development/name.md\n        ],\n        'response_config' =\u003e [],              // response config, see detail on \tpr\\models\\ResponseModel.\n\n        'default_content_type_cgi'  =\u003e 'html', // default content-type on cgi mode\n        'default_content_type_ajax' =\u003e 'json', // default content-type on api request\n        'default_content_type_cli'  =\u003e 'text', // default content-type on command line mode\n\n        'dispatch_rule' =\u003e '{app_namespace}\\{module}\\controller\\{controller}',  // controller namespace spelling rule\n    ])\n    -\u003erun();\n\n```\n\n## Events\n\n|event name | params |\n|:---:|:---:|\n|worker_init|(Workerman\\Worker $worker)|\n|worker_start|(Workerman\\Worker $worker)|\n|worker_reload|(Workerman\\Worker $worker)|\n|worker_connect|(Workerman\\Connection\\ConnectionInterface $connection)|\n|worker_close|(Workerman\\Connection\\ConnectionInterface $connection)|\n|worker_buffer_full|(Workerman\\Connection\\ConnectionInterface $connection)|\n|worker_buffer_brain|(Workerman\\Connection\\ConnectionInterface $connection) |\n|worker_error|(Workerman\\Connection\\ConnectionInterface $connection, $code, $msg)|\n|worker_message|(Workerman\\Connection\\ConnectionInterface $connection, Workerman\\Protocols\\Http\\Request $request)|\n\n## License\n\nThe project is open-sourced software licensed under the [MIT](LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxiosleo%2Ftpr-workerman","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faxiosleo%2Ftpr-workerman","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxiosleo%2Ftpr-workerman/lists"}