{"id":26725672,"url":"https://github.com/idrunk/dce-php","last_synced_at":"2025-08-02T02:11:49.610Z","repository":{"id":50520659,"uuid":"110273750","full_name":"idrunk/dce-php","owner":"idrunk","description":"🌏 一款以通用架构进行HTTP、TCP、WEBSOCKET、命令行等编程的框架","archived":false,"fork":false,"pushed_at":"2023-12-22T10:52:58.000Z","size":583,"stargazers_count":15,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-08T02:48:32.213Z","etag":null,"topics":["dce","microservice","network","orm","server","swoole","websocket"],"latest_commit_sha":null,"homepage":"https://drunkce.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/idrunk.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,"zenodo":null}},"created_at":"2017-11-10T17:23:55.000Z","updated_at":"2023-04-20T15:15:47.000Z","dependencies_parsed_at":"2023-12-22T12:31:38.938Z","dependency_job_id":null,"html_url":"https://github.com/idrunk/dce-php","commit_stats":null,"previous_names":["idrunk/dce"],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/idrunk/dce-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idrunk%2Fdce-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idrunk%2Fdce-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idrunk%2Fdce-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idrunk%2Fdce-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/idrunk","download_url":"https://codeload.github.com/idrunk/dce-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idrunk%2Fdce-php/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268326728,"owners_count":24232495,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["dce","microservice","network","orm","server","swoole","websocket"],"created_at":"2025-03-27T21:19:58.247Z","updated_at":"2025-08-02T02:11:49.565Z","avatar_url":"https://github.com/idrunk.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DCE\n\nDce是一款基于PHP8开发的网络编程框架，支持传统Cgi式Web编程及命令行工具编程，也支持Swoole下常驻内存式Web编程与长连接服务器编程，并且设计了一套通用的RCR架构处理所有类型网络编程，让你的应用项目保持清晰整洁，助你轻松编写出易复用、好维护的代码。\n\n![RCR架构流程图](https://drunkce.com/assets/img/rcr.728a5b53.svg)\n\nDce还有很多特色功能，其中最为重量级的是 ~~分库中间件~~，可以让你轻松实现分库查询。除此之外还提供有负载均衡连接池、远程过程调用、ID生成器、并发锁、会话管理器等特色功能，这些功能依赖Swoole，Dce作者也强烈推荐你在Swoole下使用Dce，配合其多进程协程模式，可以将你的服务器性能发挥到极致。\n\n当然，除了上述功能外，如模型、校验器、缓存器、事件、查询器、活动记录等这些常规的功能模块也必不可能缺少。\n\n\n\n### 开始使用\n\n\n#### 获取\n\n```shell\ncomposer create-project idrunk/dce-app:@dev\n```\n\n取用例\n```shell\ncomposer create-project idrunk/dce-app:dev-sample dce-sample\n```\n\n\n#### 使用命令行工具\n\n执行一个空命令\n```shell\n./dce\n# 或者在windows下执行:\n.\\dce.bat\n# 将响应:\n#\n# 你正在cli模式以空路径请求Dce接口\n```\n\n在有Swoole的Linux下启动Websocket服务器\n```shell\ndce websocket start\n# 将响应\n# Websocket server started with 0.0.0.0:20461.\n```\n\nJS连接Websocket服务\n```js\nconst ws = new WebSocket('ws://127.0.0.1:20461');\nws.onopen = () =\u003e ws.send('');\nws.onmessage = msg =\u003e console.log(msg.data);\n// 若连接成功，将在控制台打印出下述消息\n/*\n;{\"data\":{\"info\":\"恭喜！服务端收到了你的消息并给你作出了回应\"}}\n*/\n```\n\n\n#### 使用Redis连接池\n\nRedisProxy会自动根据环境判定从实例池取还是新建连接，若使用实例池，则会自动取还。\n```php\nRedisProxy::new()-\u003eset('homepage', 'https://drunkce.com');\n```\n\n\n#### 数据库查询\n\n分库查询需要进行分库规则配置，但查询方法和普通查询没区别，所以下述示例也适用于分库查询。\n```php\n// 查一条\n$row = db('member')-\u003ewhere('mid', 4100001221441)-\u003efind();\n// db方法为实例化查询器的快捷方法\n\n// 简单联合查询\n$list = db('member', 'm')-\u003ejoin('member_role', 'mr', 'mr.mid = m.mid')-\u003eselect();\n\n// 较复杂的嵌套条件查询\n$list = db('member')-\u003ewhere([\n    ['is_deleted', 0],\n    ['register_time', 'between', ['2021-01-01', '2021-01-31 23:59:59']],\n    [\n        ['level', '\u003e', 60],\n        'or',\n        ['vip', '\u003e', 1],\n    ],\n    ['not exists', raw('select 1 from member_banned where mid = member.mid')],\n])-\u003eselect();\n```\n\n\u003cbr\u003e\n\n通过上述的简介，相信你对Dce已经有了一个初步认识，Dce的玩法远不止这些，你可以[点击这里](https://drunkce.com/guide/)继续深入了解。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidrunk%2Fdce-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidrunk%2Fdce-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidrunk%2Fdce-php/lists"}