{"id":14966605,"url":"https://github.com/itswuanran/yii2-tech","last_synced_at":"2025-04-09T14:15:46.393Z","repository":{"id":107564455,"uuid":"76456656","full_name":"itswuanran/yii2-tech","owner":"itswuanran","description":"Yii2 实践","archived":false,"fork":false,"pushed_at":"2022-09-20T08:04:17.000Z","size":35391,"stargazers_count":194,"open_issues_count":0,"forks_count":88,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-03-30T00:53:29.677Z","etag":null,"topics":["admin","adminlte","audit","calendar","management-system","oauth2","php","yii2","yii2-framework"],"latest_commit_sha":null,"homepage":"","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/itswuanran.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2016-12-14T12:13:41.000Z","updated_at":"2025-02-23T06:02:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"e0f6c55a-d352-4139-add2-228edb354102","html_url":"https://github.com/itswuanran/yii2-tech","commit_stats":null,"previous_names":["itswuanran/yii2-tech","anruence/yii2-tech"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itswuanran%2Fyii2-tech","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itswuanran%2Fyii2-tech/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itswuanran%2Fyii2-tech/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itswuanran%2Fyii2-tech/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itswuanran","download_url":"https://codeload.github.com/itswuanran/yii2-tech/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248054194,"owners_count":21039952,"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":["admin","adminlte","audit","calendar","management-system","oauth2","php","yii2","yii2-framework"],"created_at":"2024-09-24T13:36:40.672Z","updated_at":"2025-04-09T14:15:46.368Z","avatar_url":"https://github.com/itswuanran.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 后台管理系统beta\n\n## 安装说明：\n\n```bash\ngit clone https://github.com/anruence/yii2-tech.git\n\ncd yii2-tech\n\ncomposer install --no-dev\n```\n\n## 数据库迁移\n \n - 先解压tech.sql.zip文件。\n - tech.sql中保存了sql语句，暂时没写migrate脚本。后续会扩展。\n - 后台 用户名：test 密码：testpass\n\n修改测试环境的common/config/main-local.php文件\n\n\u003e environments/dev/common/config/main-local.php\n\n正式环境对应\n\u003e environments/prod/common/config/main-local.php\n\n```php\n\u003c?php\nreturn [\n    'components' =\u003e [\n        'db' =\u003e [\n            'class' =\u003e 'yii\\db\\Connection',\n            'dsn' =\u003e 'mysql:host=localhost;dbname=tech',\n            'username' =\u003e 'your-username',\n            'password' =\u003e 'your-password',\n            'charset' =\u003e 'utf8',\n        ],\n        //...\n    ],\n];\n\n```\n\n```bash\nphp yii migrate\n\nphp yii migrate --migrationPath=@yii/rbac/migrations\n\n## 使用了yii2-admin组件，如果需要配置菜单执行下面命令\n\nphp yii migrate --migrationPath=@mdm/admin/migrations\n\n## 集成了yii2-audit组件，如需使用迁移表即可\n\nphp yii migrate --migrationPath=@bedezign/yii2/audit/migrations\n\n```\n\n提供了sql文件，可以用命令直接导入。\n\n```bash\nmysql -uusername -ppassword dbname \u003c tech.sql\n```\n\n\n\n## 效果图\n\n- 前端页面\n![前端页面](https://github.com/anruence/yii2-tech/raw/master/docs/tech.png\n \"前端页面\")\n- 后台管理\n![后台管理](https://github.com/anruence/yii2-tech/raw/master/docs/backend.png\n \"后台管理\")\n- 商品管理(详情页集成ckeditor)\n![商品管理](https://github.com/anruence/yii2-tech/raw/master/docs/oneproduct.png\n \"商品管理\")\n- 树形分类\n![树形分类](https://github.com/anruence/yii2-tech/raw/master/docs/category.png\n \"树形分类\")\n- audit访问记录\n![audit](https://github.com/anruence/yii2-tech/raw/master/docs/audit.png\n \"audit\")\n![trails](https://github.com/anruence/yii2-tech/raw/master/docs/trails.png\n \"trails\")\n- calendar展示\n![calendar](https://github.com/anruence/yii2-tech/raw/master/docs/calendar.png\n \"calendar\")\n\n## nginx配置\n\n建议配置多个二级域名\n\n```\n# 支付端\nserver {\n    listen       80;\n    server_name  pay.domain.app;\n    root  /data/yii2-tech/pay/web;\n    index index.php;\n    location / {\n        try_files $uri /index.php?$args;\n        # index index.php index.html;\n    }\n\n    location ~ \\.php$ {\n        fastcgi_index  index.php;\n        fastcgi_pass unix:/var/run/php7.0-fpm.sock;\n        # fastcgi_pass 127.0.0.1:9000;\n        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n        include fastcgi_params;\n    }\n}\n# 博客端\nserver {\n    listen       80;\n    server_name  tech.domain.app;\n    root  /data/yii2-tech/tech/web;\n    index index.php;\n    location / {\n        try_files $uri /index.php?$args;\n        # index index.php index.html;\n    }\n\n    location ~ \\.php$ {\n        fastcgi_index  index.php;\n        fastcgi_pass unix:/var/run/php7.0-fpm.sock;\n        # fastcgi_pass 127.0.0.1:9000;\n        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n        include fastcgi_params;\n    }\n}\n# 后端mis\nserver {\n    listen       80;\n    server_name  mis.domain.app;\n    root  /data/yii2-tech/backend/web;\n    index index.php;\n    location / {\n        try_files $uri /index.php?$args;\n        # index index.php index.html;\n    }\n\n    location ~ \\.php$ {\n        fastcgi_index  index.php;\n        fastcgi_pass unix:/var/run/php7.0-fpm.sock;\n        # fastcgi_pass 127.0.0.1:9000;\n        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n        include fastcgi_params;\n    }\n}\n\n# 前端应用\nserver {\n    listen       80;\n    server_name  www.domain.app;\n    root  /data/yii2-tech/frontend/web;\n    index index.php;\n    location / {\n        try_files $uri /index.php?$args;\n        # index index.php index.html;\n    }\n\n    location ~ \\.php$ {\n        fastcgi_index  index.php;\n        fastcgi_pass unix:/var/run/php7.0-fpm.sock;\n        # fastcgi_pass 127.0.0.1:9000;\n        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n        include fastcgi_params;\n    }\n}\n```\n\n## elasticsearch接入（TODO）\n\n## OAuth2.0配置\n\n### 添加oauth2.0的配置文件\n\n```php\n    'modules' =\u003e [\n        'oauth2' =\u003e [\n            'class' =\u003e 'filsh\\yii2\\oauth2server\\Module',\n            'tokenParamName' =\u003e 'accessToken',\n            'tokenAccessLifetime' =\u003e 3600 * 24,\n            'storageMap' =\u003e [\n                'user_credentials' =\u003e 'frontend\\models\\User'\n            ],\n            'grantTypes' =\u003e [\n                'client_credentials' =\u003e [\n                    'class' =\u003e 'OAuth2\\GrantType\\ClientCredentials',\n                    'allow_public_clients' =\u003e false\n                ],\n                'user_credentials' =\u003e [\n                    'class' =\u003e 'OAuth2\\GrantType\\UserCredentials'\n                ],\n                'refresh_token' =\u003e [\n                    'class' =\u003e 'OAuth2\\GrantType\\RefreshToken',\n                    'always_issue_new_refresh_token' =\u003e true\n                ]\n            ],\n        ],\n    ],\n    'components' =\u003e [\n        'urlManager' =\u003e [\n            'enablePrettyUrl' =\u003e true,\n            'showScriptName' =\u003e false,\n            'rules' =\u003e [\n                'POST oauth2/\u003caction:\\w+\u003e' =\u003e 'oauth2/rest/\u003caction\u003e',\n            ],\n        ],\n    ]\n```\n### 创建Oauth Server所需数据表\n```\nphp yii migrate --migrationPath=@vendor/filsh/yii2-oauth2-server/migrations\n```\n原作者的migrate脚本有些小问题，参见：\nhttps://github.com/Filsh/yii2-oauth2-server/issues/109\n在composer仓库中的版本并未修复，正确代码参考：https://github.com/Filsh/yii2-oauth2-server/blob/master/migrations/m140501_075311_add_oauth2_server.php\n在oauth_client表中有一条测试记录，需要将http://fake/修改成自定义的domain name。(本例中为：http://api.domain.app)\n\n### 模拟发送Post请求(Postman)\n- 获取token\nhttp://api.domain.app/oauth/token\n\n```\ngrant_type:password\nusername:tuser\npassword:tpass\nclient_id:testclient\nclient_secret:testpass\n```\n- GET 请求获取code\nhttp://api.tech.app/oauth/authorize?response_type=code\u0026client_id=testclient\u0026redirect_uri=http://api.tech.app/oauth/authcode\u0026state=xyz\n获取code，然后code换token。\n```\ngrant_type:authorization_code\ncode:code\nclient_id:testclient\nclient_secret:dbsecret\nredirect_uri:http://api.tech.app/oauth/authcode\n```\n\n## sso系统（TODO）\n\n## 支付系统\n\n\u003e 微信（支持多商户，APP \u0026 H5）\n\n\u003e 支付宝（支持多商户，APP \u0026 H5）\n\n## 增加seotools配置\n```\nphp yii migrate --migrationPath=@vendor/jpunanua/yii2-seotools/migrations\n\n```\n### seotools路由\n- seotools/manage\n- seotools/manage/create\n\n\n## 备注\n\n 本项目主要是Yii2常见组件的使用积累，仅供学习参考，如需线上应用请folk然后自由定制自己所需功能。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitswuanran%2Fyii2-tech","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitswuanran%2Fyii2-tech","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitswuanran%2Fyii2-tech/lists"}