PHP开源框架-StarFramework

qq_31754595 2015-10-04 11:11:22
写了一个简单实用的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构建应用程序之路。
...全文
807 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
HowgoO 2016-06-22
  • 打赏
  • 举报
回复
貌似不错哦。多多推广。
qq_31754533 2015-10-16
  • 打赏
  • 举报
回复
支持下,不错!
qq_31754595 2015-10-04
  • 打赏
  • 举报
回复
引用 1 楼 xuzuning 的回复:
入口文件(index.php)在子目录(public)中? 如果要做多个项目,该如何布局?
入口文件放在public主要是考虑安全问题。 放哪都可以,开发者是自己定义,只要能保证安全的情况下。
xuzuning 2015-10-04
  • 打赏
  • 举报
回复
入口文件(index.php)在子目录(public)中? 如果要做多个项目,该如何布局?

4,251

社区成员

发帖
与我相关
我的任务
社区描述
国内外优秀PHP框架讨论学习
社区管理员
  • Framework
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧