{"id":20519640,"url":"https://github.com/xiao555/router-php","last_synced_at":"2026-04-21T04:32:35.256Z","repository":{"id":85749201,"uuid":"79423370","full_name":"xiao555/router-php","owner":"xiao555","description":"A PHP register/login Demo with router function","archived":false,"fork":false,"pushed_at":"2017-02-16T14:05:23.000Z","size":607,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-06T00:17:08.980Z","etag":null,"topics":["php-demo","php-router","router"],"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/xiao555.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-19T06:36:56.000Z","updated_at":"2020-10-07T02:54:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"390494f5-1f1e-4d1d-894b-dea83b897a4f","html_url":"https://github.com/xiao555/router-php","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xiao555/router-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiao555%2Frouter-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiao555%2Frouter-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiao555%2Frouter-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiao555%2Frouter-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xiao555","download_url":"https://codeload.github.com/xiao555/router-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiao555%2Frouter-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32076947,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T02:38:07.213Z","status":"ssl_error","status_checked_at":"2026-04-21T02:38:06.559Z","response_time":128,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["php-demo","php-router","router"],"created_at":"2024-11-15T22:15:20.116Z","updated_at":"2026-04-21T04:32:35.242Z","avatar_url":"https://github.com/xiao555.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 带简单的Router功能的PHP注册登录Demo\n\n### 环境\n\n  1. MacOS\n  2. XAMPP\n\n### 配置数据库和安装依赖\n\n1. 执行sql脚本 `init.php` 创建所需的数据库和表\n2. 配置 `/Models/database.json` 填上root密码\n3. 安装依赖 `composer install`\n\n### 配置服务器通过域名访问\n\n这个方法已经可以放弃了。。。直接被服务器访问就行，就不删了\n\n1. 修改hosts\n\n```bash\nsudo nano /etc/hosts\n```\n\n在最后添加: `127.0.0.1      localtest # 你想设置的域名`\n\n2. 开启虚拟主机\n\n修改xampp配置，编辑`/Applications/XAMPP/xamppfiles/etc/httpd.conf`\n搜索`httpd-vhosts.conf`，把这行前面的注释去掉，在最后加上这样一段：\n\n```conf\n\u003cDirectory \"/Applications/XAMPP\"\u003e\n    #Options Indexes FollowSymLinks ExecCGI Includes #don't \u003epermission see list\n    Options All\n    AllowOverride All\n    Order allow,deny\n    Allow from all\n\u003c/Directory\u003e\n```\n\n3. 配置虚拟主机\n\n编辑`/Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf`\n\n```conf\n\u003cVirtualHost *:80\u003e\n    DocumentRoot  \"/Applications/XAMPP/xamppfiles/htdocs/php-login-register/\"\n    ServerName localtest\n\u003c/VirtualHost\u003e\n\n\u003cVirtualHost *:80\u003e\n    DocumentRoot \"/Applications/XAMPP/xamppfiles/htdocs/\"\n    ServerName localhost\n\u003c/VirtualHost\u003e\n```\n\n\n### 运行\n\n1. 普通方法\n\n    本地直接访问即可，例如: `127.0.0.1/php-login-register/`(注意最后一个`/`).\n2. 配置虚拟主机\n\n    重启xampp，在本地服务器上，浏览器打开[localhost](localhost) 、 [localtest](localtest) 以及 [127.0.0.1](127.0.0.1) 看看效果。\n    另外，也可以找一个闲置的域名解析成127.0.0.1，这样访问域名就会解析到本地。\n\n### 说明\n\n前身是 [简单的PHP注册登录Demo](https://github.com/xiao555/PHP-register-login) 在此基础上进行改造。\n\n首先，要实现路由功能，网站的入口只有一个，index.php\n这就需要配置一下`.htaccess`伪静态，关于`.htaccess`的可以参考[.htaccess基本语法和应用](http://blog.sina.com.cn/s/blog_6e8b46e701014drc.html)\n\nrouter逻辑是用的[phroute](https://github.com/mrjgreen/phroute).\n\n目前逻辑都写在`index.php`里，模板放在`Views`目录下，封装了两个自定义函数`render`和 `redirect`，实现模板分离已经够用了。\n\n密码采用hash加密，增强了安全性(==!).\n\n不足：\n\n  1. `phroute` 还不是很熟悉，需要研究\n  2. `.htaccess`的配置需要学习一下\n  3. 还需要加个`/Public`存放静态资源\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiao555%2Frouter-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxiao555%2Frouter-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiao555%2Frouter-php/lists"}