├── app ├── cache │ └── out │ │ └── readme.md ├── log │ └── readme.md ├── language │ └── zh_CN │ │ └── LC_MESSAGES │ │ └── readme.md └── page │ └── Home.php ├── .gitignore ├── .gitmodules ├── nginx.conf ├── web ├── .htaccess └── index.php ├── config └── db.php ├── Readme.md └── sys └── config.php /app/cache/out/readme.md: -------------------------------------------------------------------------------- 1 | ### 缓存文件目录 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /app/log/*.log 2 | .idea/* -------------------------------------------------------------------------------- /app/log/readme.md: -------------------------------------------------------------------------------- 1 | ### 日志记录文件夹,以日期归档 -------------------------------------------------------------------------------- /app/language/zh_CN/LC_MESSAGES/readme.md: -------------------------------------------------------------------------------- 1 | ### 语言文件夹 -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "sys/core"] 2 | path = sys/core 3 | url = git@github.com:loveyu/php-framework-module.git 4 | -------------------------------------------------------------------------------- /nginx.conf: -------------------------------------------------------------------------------- 1 | location / { 2 | if (!-f $request_filename){ 3 | rewrite (.*) /index.php; 4 | } 5 | } 6 | error_page 404 /index.php; 7 | -------------------------------------------------------------------------------- /web/.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine On 2 | RewriteBase / 3 | 4 | #不存在的文件直接重定向 5 | RewriteCond %{REQUEST_FILENAME} !-f 6 | RewriteRule ^(.*)$ /index.php [L] 7 | 8 | -------------------------------------------------------------------------------- /web/index.php: -------------------------------------------------------------------------------- 1 | getTimer()->setBeginTime($time); //修正启动时间 5 | cfg()->load(_ConfigPath_.'/db.php'); //加载其他配置文件 6 | u()->home(array( 7 | 'Home',//默认主页 8 | 'main', 9 | ), array( 10 | 'Home',//默认404 11 | 'not_found', 12 | )); -------------------------------------------------------------------------------- /app/page/Home.php: -------------------------------------------------------------------------------- 1 | get()); 14 | } 15 | 16 | public function not_found() { 17 | send_http_status(404); 18 | echo "This is 404 page."; 19 | } 20 | } -------------------------------------------------------------------------------- /config/db.php: -------------------------------------------------------------------------------- 1 | [ 7 | 'write' => [ 8 | 'database_type' => 'mysql', //服务器类型 支持 mysql ,请勿修改 9 | 'server' => 'localhost', //服务器地址 10 | 'username' => 'root', //用户名 11 | 'password' => '123456', //密码 12 | 'database_file' => '', //数据库文件, SqLite 专有文件 13 | 'charset' => 'utf8', //编码 14 | 'database_name' => 'test', //数据库名 15 | 'option' => [ //PDO选项 16 | PDO::ATTR_CASE => PDO::CASE_NATURAL, 17 | PDO::ATTR_TIMEOUT => 5, 18 | ], 19 | ], 20 | ], 21 | ); -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # 基本的PHP整体结构运行样例程序 2 | 3 | ## 系统需求 4 | PHP版本必须大于等于`5.4` 5 | 6 | ## 安装步骤 7 | Clone Git,过程中必须包含子项目,否则将导致直接不可用 8 | ``` 9 | git clone --recurse-submodules git@github.com:loveyu/php-framework-module-example.git 10 | ``` 11 | 12 | ## 网站配置 13 | 由于完全依赖于伪静态,所以必须对文件进行重定向。 14 | 15 | ### nginx配置 16 | ``` 17 | location / { 18 | if (!-f $request_filename){ 19 | rewrite (.*) /index.php; 20 | } 21 | } 22 | # 重定向404页面,防止静态资源404无法获取 23 | error_page 404 /index.php; 24 | ``` 25 | 26 | ### Apache 配置 27 | ``` 28 | RewriteEngine On 29 | RewriteBase / 30 | 31 | #不存在的文件直接重定向 32 | RewriteCond %{REQUEST_FILENAME} !-f 33 | RewriteRule ^(.*)$ /index.php [L] 34 | ``` 35 | 36 | 同时,对于Apache也可以使用PATH_INFO的形式,如 `index.php/Home` . 37 | 38 | 系统默认将Web配置目录放到web文件夹下,其他对应的文件sys,app等文件均在web目录的上级目录, 39 | 这是为了安全性的考虑,如果有需要将文件调整到一个目录,可具体参考`sys/config.php`文件调整目录结构,并调整index.php文件的具体参数 -------------------------------------------------------------------------------- /sys/config.php: -------------------------------------------------------------------------------- 1 |