PHP开源框架-StarFramework

qq_31754595 qq_31754595 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
写了一个简单实用的PHP框架,包含完整的开发文档和提供后台管理权限demo,有兴趣的可以了解下哈,有什么不合理或者好建议,都可以帮忙提出来哈。
官方网站: StarFramework
框架目录结构

+ public
| - .htaccess // Rewrite rules
| - index.php // Application entry
| + static
| + css
| + js
| + img
- application/
- Bootstrap.php // Bootstrap
+ configs
| - application.ini // Configure
+ controllers
- IndexController.php // Default controller
+ layouts
| + default
- layout.phtml // layout
+ logs //Log
+ models //Model
+ services //Service
+ views
| + scripts
|+ index
- index.phtml // View template for default controller
+ library
| + Star //Star Framework


服务器环境要求

PHP最低版本: 5.2+
配置

SF初始添加环境变量,无需任何配置即可使用, SF支持Star_Config_Ini和Star_Config_Php两种适配器。环境变量初始值必须包含入口文件定义APPLICATION_ENV值,环境变量用来区分测试环境和线上环境配置。配置文件配好各个环境配置,可以直接修改入口文件APPLICATION_ENV值切换配置。
PHP配置

<?php
return array(
"production" => array( //环境变量
"bootstrap" => array( //bootstrap设置
"path" => APPLICATION_PATH . "/Bootstrap.php", //bootstrap路径
),
"resources" => array(
"frontController" => array(
"debug" => true, //是否打开debug模式
),
),
),
);
?>


INI配置

[production]
;bootstrap路径
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
;bootstrap类名
bootstrap.class = "Bootstrap"


权限设置

SF日志目录是需要权限设置,application/logs目录需要设置为可写入权限。
WEB服务器

指定WEB根目录到sf_path/public目录,开启WEB服务器Rewrite模块。
apache配置

# 设置文档根目录为 “sf_path/public”
DocumentRoot "sf_path/public"
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule !\.(js|css|png|jpg|jpeg|gif|swf|ico|html|htm)$ index.php [NC,L]

nginx rewrite规则

server {
listen 80;
server_name www.yoursf.com;

location / {
root sf_path/public;
index index.php;
if (!-e $request_filename) {
rewrite ^/(.*) /index.php/$1 last;
}
}

location ~* \.(js|css|png|jpg|jpeg|gif|swf|ico|html|htm)$ {
break;
}

location ~ \.php$ {
root sf_path/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

location ~ /\.ht {
deny all;
}
}


运行

安装完成后,你可以使用浏览器输入如下URL访问刚安装完毕的SF应用:

http://www.yoursf.com/


你将会看到SF影响缺省页面,恭喜您!开始基于SF构建应用程序之路。
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
qq_31754595
Framework 4,250 成员 4,522 内容