{"id":20762526,"url":"https://github.com/welllog/oyaf","last_synced_at":"2026-04-11T02:46:38.367Z","repository":{"id":44202215,"uuid":"176296982","full_name":"welllog/oyaf","owner":"welllog","description":"php frame with grpc,db,cache,log","archived":false,"fork":false,"pushed_at":"2022-02-11T02:47:46.000Z","size":84,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-18T05:42:45.208Z","etag":null,"topics":["cassandra","elasticsearch","grpc","mysql"],"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/welllog.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":"2019-03-18T13:54:21.000Z","updated_at":"2022-02-11T02:47:41.000Z","dependencies_parsed_at":"2022-08-26T08:51:51.510Z","dependency_job_id":null,"html_url":"https://github.com/welllog/oyaf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/welllog%2Foyaf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/welllog%2Foyaf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/welllog%2Foyaf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/welllog%2Foyaf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/welllog","download_url":"https://codeload.github.com/welllog/oyaf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243079552,"owners_count":20233004,"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":["cassandra","elasticsearch","grpc","mysql"],"created_at":"2024-11-17T10:35:54.460Z","updated_at":"2025-12-24T03:35:23.609Z","avatar_url":"https://github.com/welllog.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 基于yaf搭建补充的项目快速开发框架\n\n### 环境要求\n1. php \u003e= 7.1\n2. yaf框架扩展\n3. php.ini配置``yaf.use_namespace=1``\n\n### nginx配置参考\n```\nserver {\n  listen ****;\n  server_name  domain.com;\n  root   document_root/public;\n  index  index.php index.html index.htm;\n\n  if (!-e $request_filename) {\n    rewrite ^/(.*)  /index.php/$1 last;\n  }\n\n  location ~ \\.php {\n          try_files  $uri =404;\n          fastcgi_split_path_info  ^(.+\\.php)(/.+)$;\n          fastcgi_pass   127.0.0.1:9000;\n          fastcgi_index  index.php;\n          fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;\n          fastcgi_param  SCRIPT_NAME  $fastcgi_script_name;\n          include        fastcgi_params;\n  }\n}\n```\n\n\n###### 成功提示\n\u003e composer install安装，访问http://yourhost/index/,出现Hellow Word!, 表示运行成功,否则请查看php错误日志;\n\n#### 配置\n\u003e* conf目录下\n\u003e* 重要配置：\n\u003e\u003e 1. application.ini中配置loglevel日志级别\n\u003e\u003e 2. application.ini中配置cachedriver缓存驱动，仅实现了file,redis驱动\n\u003e\u003e 3. app.php中定义常量RUN_MODE运行环境\n\u003e\u003e 4. dbconf.php中数据库连接配置\n\n#### tips\n* 缓存实现了psr-16标准，需要替换或增加缓存驱动，修改application/library/Ocache/Cache.php即可\n* 日志实现了psr-3标准，目前实现了file,elasticsearch写入日志，如需扩展仅需实现application/library/Olog/Output接口,并在\napplication/Bootstrap.php中注入\n* 验证器采用了vlucas/valitron，查看相关文档地址:https://github.com/vlucas/valitron\n\n#### sql查询构造器(详细用法查看代码)\n\u003e* DB::table('user')-\u003einsert(['name' =\u003e 'jack', 'age' =\u003e 24]);\n\u003e* DB::table('user')-\u003einsert([['name' =\u003e 'linda', 'age' =\u003e 21], ['name' =\u003e 'bob', 'age' =\u003e 24]]);\n\u003e* DB::table('user')-\u003ewhere('id', '=', 1)-\u003eupdate(['name' =\u003e 'remi']);\n\u003e* whereNull('username')\n\u003e* whereNotNull('username')\n\u003e* whereIn('id', [1, 2, 3])\n\u003e* whereNotIn('id', [1, 2, 3])\n\u003e* whereBetween('id', [1, 9])\n\u003e* whereNotBetween('id', [1, 9])\n\u003e* whereColumn('id', '\u003e', 'parent_id')\n\u003e* where('username', '=', 'job')-\u003ewhere('age', '\u003e', 23)\n\u003e* where([['username', '=', 'job'], ['age', '\u003e', 23]])\n\u003e* whereRaw('`id`\u003e? and `status`=?', [10, 1])\n\n#### cql(cassandra)查询构造器\n\u003e* CDB::table('test')-\u003ewhere('id', 11)-\u003ewhere('name', 'bc')-\u003eupdate(['address' =\u003e 'asa']);\n\u003e* CDB::table('test')-\u003ewhere('id', 12)-\u003eupdate(['address' =\u003e 'ascdascx']);\n\u003e* CDB::table('test')-\u003ewhere('id',1)-\u003ewhere('name', 'io')-\u003edelete();\n\u003e* CDB::table('test')-\u003einsert(['id' =\u003e 10, 'name' =\u003e 'a']);\n\u003e* CDB::table('test')-\u003epage(2, 2, 'id', function($row) {\n\u003e*    $row['count'] = $row['count']-\u003etoInt();\n\u003e*    return $row;\n\u003e* });\n\u003e* $future = CDB::table('test')-\u003easync()-\u003eget();  // 异步\n\u003e* $future-\u003eget();  // 获取异步执行结果\n\u003e* $db = CDB::connect();\n\u003e* $db-\u003ebatch(); // 批处理开始\n\u003e* $db-\u003etable('test')-\u003ewhere('id', 1)-\u003eupdate(['name' =\u003e 'linda']);\n\u003e* $db-\u003etable('test')-\u003ewhere('id', 2)-\u003eupdate(['age' =\u003e 24]);\n\u003e* $db-\u003ebatchExec(); // 执行批处理\n\n#### elasticsearch\n\u003e* $query = ESQuery::new()-\u003esetIndex('test')-\u003esetMust([['ids' =\u003e ['values' =\u003e [1, 2]]]])-\u003ebuild();\n\u003e* ESCli::getInstance()-\u003esearch($query)\n\n\n#### controller\n获取请求参数\n\u003e* $this-\u003egetPost()\n\u003e* $this-\u003egetPostForm()\n\u003e* $this-\u003egetQuery()\n\u003e* $this-\u003egetParams()\n\n验证参数\n\u003e $this-\u003emakeValidator($params)-\u003erule(...)-\u003evalidate()\n\n返回json响应(注意必须加上return)\n\u003e return $this-\u003eajaxReturn()\n\n#### model\n* $userModel-\u003eall()\n* $userModel-\u003efind($userid);\n* $userModel-\u003ewhere(...)\n* $userModel-\u003ebuildQuery()-\u003ewhere(...)-\u003efirst()\n\nmodel属性设置\n* protected $table = 'user';\n* protected $primaryKey = 'id';\n* protected $connect = 'default'\n\n#### 缓存\n\u003e* Cache::get(string $key)\n\u003e* Cache::set(string $key, string $value, int $timeout)\n\u003e* Cache::delete(string $key)\n\u003e* Cache::getMultiple(array $keys)\n\u003e* Cache::setMultiple([$key1 =\u003e $value1])\n\u003e* Cache::deleteMultiple(array $keys)\n\u003e* Cache::has(string $key)\n\u003e* Cache::increment(string $key)\n\u003e* Cache::decrement(string $key)\n\n#### 日志\n\u003e* Log::debug(string $msg)\n\u003e* Log::info(string $msg)\n\u003e* Log::notice(string $msg)\n\u003e* Log::warning(string $msg)\n\u003e* Log::error(string $msg)\n\u003e* Log::critical(string $msg)\n\u003e* Log::alert(string $msg)\n\u003e* Log::flush()\n\n#### 限流\n\u003e* (new RateLimit(10, 60, $redis))-\u003esafeActAllow($userid, $action);\n\u003e* (new RateLimit(10, 60, $redis))-\u003esimActAllow($userid, $action);\n\n#### grpc client\n\u003e* $req = new \\Api\\Hello();\n\u003e* $req-\u003esetHello('world');\n\u003e* $cli = new \\Rpc\\GrpcClient(\\Api\\HelloServiceClient::class, $address);\n\u003e* // 同步执行\n\u003e* $reply = $cli-\u003esetRequest($req)-\u003ecall('SayHello');\n\u003e* echo  $reply-\u003egetReply()-\u003egetHello() . PHP_EOL;\n\u003e* // 异步执行\n\u003e* $async = $cli-\u003esetRequest($req)-\u003eascyncExec('SayHello');\n\u003e* echo $async-\u003ewait()-\u003egetReply()-\u003egetHello() . PHP_EOL;\n\n ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwelllog%2Foyaf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwelllog%2Foyaf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwelllog%2Foyaf/lists"}