# SinglePHP-Ex
**Repository Path**: MisterTiger/SinglePHP-Ex
## Basic Information
- **Project Name**: SinglePHP-Ex
- **Description**: SinglePHP-Ex 是一个单文件PHP框架,提供了精简的MVC模式,简单的快速开发系统。
- **Primary Language**: PHP
- **License**: MIT
- **Default Branch**: library
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 4
- **Created**: 2023-11-04
- **Last Updated**: 2023-11-04
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# SinglePHP-Ex 2.x
### 简介
[SinglePHP-Ex 2.x](https://gitee.com/qingmukeji/SinglePHP-Ex) 是一个单文件PHP框架,提供了精简的MVC模式,简单系统的快速开发。看一眼代码和demo的内容,即可上手使用。
**基于SinglePHP-Ex的项目demo项目,请见 [Proejct](https://gitee.com/qingmukeji/SinglePHP-Ex/tree/project) 分支。**
目前 [SinglePHP-Ex](https://gitee.com/qingmukeji/SinglePHP-Ex) 由 geligaoli 开发维护,如果你希望参与到此项目中来,可以到[Github](https://github.com/geligaoli/SinglePHP-Ex)上Fork项目并提交Pull Request。
[SinglePHP-Ex](https://gitee.com/qingmukeji/SinglePHP-Ex) 是参考了 [SinglePHP](https://github.com/leo108/SinglePHP) 为原型,并整合了 [PhpPoem](https://github.com/cleey/phppoem)、Thinkphp早期 部分代码。
#### 功能的增强有:
加入了namespace的支持,默认namespace的路径和文件路径一致。采用psr-4标准。
加入了composer的支持。保持了单文件php的简单,又可以composer安装组件。
路由规则支持PATHINFO的伪静态方式,也同时支持普通QueryString的访问。
加入View的include模板功能,根据文件时间来自动生成编译后的模板缓存文件。
数据库操作改为PDO,可以在php7.x执行。支持建立多数据库连接。支持多种数据库的分页查询。
加入数据库表Model,参考thinkphp,简化对单表的增删改查的操作。
拦截php的异常错误,DEBUG状态下,在页面显示详细错误trace,方便调试。
加入了命令行模式,方便写脚本用。
整个框架不超过800行。简单明了。
#### composer 安装
环境要求PHP版本>=5.3,无其它库依赖。
composer require "geligaoli/singlephp-ex:^2.0.4"
### 文档
#### nginx的pathinfo方式配置
假如项目部署在 /www/nginx/default目录下。设置open_basedir可提高安全性。
root /www/nginx/default/Public;
index index.html index.php;
location / {
try_files $uri $uri/ =404;
}
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
}
location ~ \.php($|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param PHP_ADMIN_VALUE "open_basedir=/www/nginx/default/:/usr/share/php:/tmp/:/proc/";
}
fastcgi_params 文件中增加
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
#### View模板语法
{$vo['info']} // {$..}输出变量
{:func($vo['info'])} // {:..}调用函数
{:Url("Index/Index")} // 自动按PATH_MODE来生成url
{$content}
在浏览器访问index.php,应该会输出 Hello World #### 页面无输出的检查 请检查 Cache、Log 这两个目录及子目录是否存在且可写入。 App ├── Cache #缓存,该目录及以下 **需要写权限** │ └── Tpl #编译后的view模板缓存,**需要写权限** └── Log #日志文件夹,**需要写权限** ### 原 SinglePHP 简介 SinglePHP是一个单文件PHP框架,适用于简单系统的快速开发,提供了简单的路由方式,抛弃了坑爹的PHP模板,采用原生PHP语法来渲染页面,同时提供了widget功能,简单且实用。 目前SinglePHP由[leo108](http://leo108.com)开发维护,如果你希望参与到此项目中来,可以到[Github](https://github.com/leo108/SinglePHP)上Fork项目并提交Pull Request。 ### 原 PhpPoem 简介 PhpPoem, 如诗一般简洁优美的PHP框架 PhpPoem, a simple and beautiful php framework, php will be like poet. Home: [http://phppoem.com/](http://phppoem.com/) Author: Cleey