{"id":19136946,"url":"https://github.com/singcl/php_mvc","last_synced_at":"2026-06-19T15:32:47.121Z","repository":{"id":57051712,"uuid":"191212044","full_name":"singcl/php_mvc","owner":"singcl","description":"Simple PHP MVC Framework. ","archived":false,"fork":false,"pushed_at":"2020-09-18T10:16:16.000Z","size":2894,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-12T20:59:39.217Z","etag":null,"topics":["mvc-framework","php7"],"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/singcl.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":"2019-06-10T17:14:18.000Z","updated_at":"2020-09-18T10:16:19.000Z","dependencies_parsed_at":"2022-08-24T05:10:50.936Z","dependency_job_id":null,"html_url":"https://github.com/singcl/php_mvc","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/singcl/php_mvc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singcl%2Fphp_mvc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singcl%2Fphp_mvc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singcl%2Fphp_mvc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singcl%2Fphp_mvc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/singcl","download_url":"https://codeload.github.com/singcl/php_mvc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singcl%2Fphp_mvc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34538219,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-19T02:00:06.005Z","response_time":61,"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":["mvc-framework","php7"],"created_at":"2024-11-09T06:35:56.981Z","updated_at":"2026-06-19T15:32:47.101Z","avatar_url":"https://github.com/singcl.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![travis](https://travis-ci.org/singcl/php_mvc.svg?branch=master)](https://travis-ci.org/singcl/php_mvc)\n[![Latest Stable Version](https://poser.pugx.org/singcl/php_mvc/v/stable)](https://packagist.org/packages/singcl/php_mvc)\n[![Total Downloads](https://poser.pugx.org/singcl/php_mvc/downloads)](https://packagist.org/packages/singcl/php_mvc)\n[![Latest Unstable Version](https://poser.pugx.org/singcl/php_mvc/v/unstable)](https://packagist.org/packages/singcl/php_mvc)\n[![License](https://poser.pugx.org/singcl/php_mvc/license)](https://packagist.org/packages/singcl/php_mvc)\n[![composer.lock](https://poser.pugx.org/singcl/php_mvc/composerlock)](https://packagist.org/packages/singcl/php_mvc)\n\n1. **unable to bind listening socket for address '/run/php/php7.1-fpm.sock' no such file or directory**\n\n原因：`php-fpm` 没有启动，如下启动：\n\n```bash\n# 启动命令：\nsudo /etc/init.d/php7-fpm start\n```\n\n2. 查看Ubuntu Apache2 服务器日志\n```sh\ntail -f /var/log/apache2/*.log\n```\n\n3. remote-ssh\n\n4. 启动Apache2后打开php 网站报错\n\n```sh\nsudo apache2 start\n```\n```\nService Unavailable\nThe server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.\n```\n\n有可能是php-fpm没有启动\n```bash\nsudo /etc/init.d/php7.3-fpm start\n```\n\n5. MYSQL\n```sh\n# 启动mysql\nsudo service mysql start \n```\n一直报错\n```\n-su: 30: export: : bad variable name\n```\n最终问题定位： 在`/etc/profile` 之前添加了如下语句\n```sh\nSET NODE_HOME=/opt/node10.16.0-linux-x64\nPATH = $PAHT:NODE_HOME\n```\n删除上面自己添加的即可启动\n\n\n6. WSL 暂不支持 netstat  ss 等命令\n\n7. \n```sh\n# 查看MYSQL数据库中所有用户\nmysql\u003e SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;\n\n# 查看数据库中具体某个用户的权限\nmysql\u003e select * from mysql.user where user='singcl' \\G    \n\n#查看user表结构　需要具体的项可结合表结构来查询\nmysql\u003e desc mysql.user;\n```\n\n8. 数据库操作相关问题\n```bash\nERROR 1698 (28000): Access denied for user 'root'@'localhost'\n# 创建新的管理员账户\nhttps://stackoverflow.com/questions/39281594/error-1698-28000-access-denied-for-user-rootlocalhost\n\n#\n# 将新创建的管理员账号设置为密码链接\nERROR 1698 (28000): Access denied for user 'root'@'localhost' (using password: NO)\nhttps://www.jianshu.com/p/2b63c65caf6a\n```\n\n\n## 启动\n```sh\n# 1 启动apache2\nsudo service apache2 start\n\n# 2 启动php-fpm\nsudo service php7.3-fpm start\n\n# 3 启动mysql\nsudo service mysql start\n```\n\n9. PDO 相关问题\n\n```sh\n# 环境：Ubuntu 16.02\n```\n\n代码中使用PDO 时候返回 `PDOException: can not find driver`。 然后我们查看`phpinfo()` 确认下： PDO 显示：`drivers no value`\n\n说明PDO 链接MYSQL 驱动找不到。\n\n网上搜索这个问题，答案都是挺多的， 赞成数最多的方案：\n```sh\n# @see https://stackoverflow.com/questions/32728860/php-7-rc3-how-to-install-missing-mysql-pdo\n\n# 第一步安装\napt-get install php7.3-mysql\n\n#第二步 激活\n\n# phpenmod@see https://tecadmin.net/enable-disable-php-modules-ubuntu/\nphpenmod pdo_mysql\n\nln: failed to create symbolic link '/etc/php/7.3/cli/conf.d/20-pdo_mysql.ini': Permission denied\nrm: cannot remove '/var/lib/php/modules/7.3/cli/disabled_by_admin/pdo_mysql': Permission denied\n\n# 可以看出来这一步会在/etc/php/7.3/cli/conf.d/ 中创建一个符号链接 到/etc/php/7.3/mods-abailable/pdo_mysql.so\n# 同时创建 /var/lib/php/modules/7.3/cli/enabled_by_admin/pdo_mysql\n\n# 权限不够sudo\nsudo phpenmod pdo_mysql\n# 第三步 重启\nsudo service apache2 restart\n```\n\n然后不幸的是还是失败了！！\n\n我观察`/etc/php/7.3`中的目录 发现有个fpm。  fpm 和 cli 目录下都有php.ini 文件？\n\n**我的PHP 使用的是 apache2 fast-cgi php-fpm 方式启动的，那么配置完三个步骤我只是重启了apache， php-fpm 是不是也要重启？**\n\n```sh\nsudo service php7.3-fpm restart\n```\n\nOK!! 成功了。\n\n10. Mysql 链接不上\n\n`ERROR 1698 (28000): Access denied for user 'root'@'localhost'`\n\n@see https://stackoverflow.com/questions/39281594/error-1698-28000-access-denied-for-user-rootlocalhost\n\n11. `php -r 'phpinfo();' | grep 'mysql'`\n\n## 调试\n\nxdebug 安装文档 https://xdebug.org/docs/install#compile\n\nvscode xdebug 文档 https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug\n\n#### pecl安装php扩展\nPecl全称The PHP Extension Community Library，php社区扩展库，由社区编写，维护。\n\n使用pecl方便之处在于我们不用到处找源码包下载编译，配置，不用手动phpize,configure,make,make install,自动识别模块安装路径，\n\n我们只需要编辑php.ini配置文件开启扩展，当然我们也需要自己配置一些参数的时候可以先下载源码再构建\n\nhttps://www.cnblogs.com/hk-faith/p/8777289.html\n\n## Composer\n\n1. php composer.phar update 时候warning: `Failed to download phpunit/phpunit-mock-objects from dist: The zip extension and unzip command are both missing, skipping.`\n\n解决：没有安装zip导致的。 `sudo apt-get install zip`\n\n## Page 相关页面\n```sh\nloacalhost               # 增删改查数据库         \nloacalhost/canvas        # canvas画布相关示例\nloacalhost/scratch       # 刮刮卡示例\n```\n\n\n## Apache2 php7.3 php7.3-fpm\n\n1. 初始化配置\n```sh\nsudo apt-get install software-properties-common\nsudo add-apt-repository -y ppa:ondrej/php\nsudo apt-get update\n```\n\n2. 安装主要package\n```sh\n# https://www.zhaokeli.com/article/8496.html\nsudo apt-get install apache2 php7.3 php7.3-fpm php7.3-mysql mysql-server\n```\n\n3. **配置apache2**（关键步骤）\n``` sh\n# https://blog.csdn.net/KBellX/article/details/78980317\n# https://blog.csdn.net/margin_0px/article/details/82801045\n\n# 配置apache 使用php-fpm fcgi\nsudo ln -s /etc/apache2/mods-available/proxy.conf /etc/apache2/mods-enabled/proxy.conf\nsudo ln -s /etc/apache2/mods-available/proxy.load /etc/apache2/mods-enabled/proxy.load\nsudo ln -s /etc/apache2/mods-available/proxy_fcgi.load /etc/apache2/mods-enabled/proxy_fcgi.load\nsudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load\n\n# 配置 2 /etc/apache2/sites-enabled/000.default.conf\n1 \u003cVirtualHost *:80\u003e\n  2         # The ServerName directive sets the request scheme, hostname and port that\n  3         # the server uses to identify itself. This is used when creating\n  4         # redirection URLs. In the context of virtual hosts, the ServerName\n  5         # specifies what hostname must appear in the request's Host: header to\n  6         # match this virtual host. For the default virtual host (this file) this\n  7         # value is not decisive as it is used as a last resort host regardless.\n  8         # However, you must set it for any further virtual host explicitly.\n  9         ServerName mv.hongde.com\n 10         ServerAdmin webmaster@localhost\n 11         DocumentRoot /home/singcl/php_mvc\n 12\n 13         # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,\n 14         # error, crit, alert, emerg.\n 15         # It is also possible to configure the loglevel for particular\n 16         # modules, e.g.\n 17         #LogLevel info ssl:warn\n 18        \u003cDirectory /home/singcl/php_mvc\u003e\n 19             Options +FollowSymlinks\n 20             AllowOverride All\n 21             Require all granted\n 22        \u003c/Directory\u003e\n 23\n 24        \u003cFilesMatch \\.php$\u003e\n 25             SetHandler \"proxy:unix:/var/run/php/php7.3-fpm.sock|fcgi://localhost/\"\n 26        \u003c/FilesMatch\u003e\n 27         ErrorLog ${APACHE_LOG_DIR}/error.log\n 28         CustomLog ${APACHE_LOG_DIR}/access.log combined\n 29\n 30         # For most configuration files from conf-available/, which are\n 31         # enabled or disabled at a global level, it is possible to\n 32         # include a line for only one particular virtual host. For example the\n 33         # following line enables the CGI configuration for this host only\n 34         # after it has been globally disabled with \"a2disconf\".\n 35         #Include conf-available/serve-cgi-bin.conf\n 36 \u003c/VirtualHost\u003e\n```\n\n4. 启动\n\n```sh\n# 1 启动apache2\nsudo service apache2 start\n\n# 2 启动php-fpm\nsudo service php7.3-fpm start\n\n# 3 启动mysql\nsudo service mysql start\n```\n\n## MYSQL\n```sh\n# root 用户登录\nsudo mysql -u root -p;\n```\n```sh\n# 新建用户\ncreate user 'singcl'@'localhost' indentified by 'singcl';\n```\n```sh\n# 新建数据库\ncreate database project;\n```\n```sh\n# 授权用户singcl@localhost 拥有数据库project 的所有权;\n# https://blog.csdn.net/lindiwo/article/details/81708166\ngrant all privileges on project.* to singcl@localhost identified by 'singcl';\n# 刷新\nflush privileges;\n```\n```sh\n# 切换用户\nmysql -u singcl -p;\n\n# 在 SQL 中新建一个 project 数据库（上面已经完成），增加一个item 表、并插入两条记录，命令如下：\n#CREATE DATABASE `project` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;\nUSE `project`;\n\nCREATE TABLE `item` (\n    `id` int(11) NOT NULL auto_increment,\n    `item_name` varchar(255) NOT NULL,\n    PRIMARY KEY (`id`)\n) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;\n \nINSERT INTO `item` VALUES(1, 'Hello World.');\nINSERT INTO `item` VALUES(2, 'Lets go!');\n```\n\n@Refer: https://www.awaimai.com/128.html#51\n\n# MAC 使用系统自带的Apache和PHP-FPM 开启Apache+PHP-FPM服务\n\n1. copy一份配置文件\n```shell\ncd /etc/cd /etc/apache2/\nsudo cp httpd.conf.bak httpd.conf\n```\n\n2. 打开配置文件编辑\n```sh\nsudo vim httpd.conf\n```\n解开相关依赖模块注释，如图\n![需要解注释](./static/images/81A03208-2D7D-4B35-B231-3F5F0ACE4480.png)\n\n3. 配置web服务器目录\n\n![web根目录配置](./static/images/documentroot.jpg)\n\n4. 解开虚拟主机路径\n![web根目录配置](./static/images/vhost-path.jpg)\n\n5. 配置vhost\n```sh\nsudo vim extra/httpd-vhosts.conf\n```\n如图：\n![web根目录配置](./static/images/vhostconfig.jpg)\n\n好了，现在配置已经完成。在/data/www下建一个文件：\n```sh\ntouch index.php\n```\n```php\n\u003c?php\n  phpinfo();\n````\nOK, 访问localhost：\n![web根目录配置](./static/images/serverapi.jpg)\n\n大功告成！\n\n# 错误\n1. `php SQLSTATE[HY000] [2002] No such file or directory`\n\n解决：将数据库配置里面'localhost'改为`127.0.0.1`即可。\n\n2. 要想使.htaccess 重写规则生效的话:\n```\nAllowOverride None\n# 改为\nAllowOverride All\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsingcl%2Fphp_mvc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsingcl%2Fphp_mvc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsingcl%2Fphp_mvc/lists"}