PHP-StarFramework
Star Framework是一个简单、高效、实用的PHP框架。 官网: http://www.starframework.cn #Requirement PHP5.2+ #Layout
A classic Application directory layout:
+ 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
#DocumentRoot
you should set DocumentRoot to star_framework_path/public, thus only the public folder can be accessed by user
#index.php
<?php // Define path to application directory defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application')); // Define application environment defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production')); // Ensure library/ is on include_path set_include_path(implode(PATH_SEPARATOR, array( realpath(APPLICATION_PATH . '/../library'), get_include_path(), ))); require 'Star/Application.php'; // Create application, bootstrap, and run $application = new Star_Application( APPLICATION_ENV, APPLICATION_PATH, APPLICATION_PATH . '/configs/application.ini', //OR APPLICATION_PATH . '/configs/application.php', realpath(APPLICATION_PATH . '/../library') ); $application->bootstrap()->run();
#Rewrite rules Apache
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
server {
listen ****;
server_name domain.com;
root document_root;
index index.php index.html index.htm;
location ~* .(js|css|png|jpg|jpeg|gif|swf|ico|html|htm)$ {
break;
}
if (!-e $request_filename) {
rewrite ^/(.*) /index.php last;
}
}
#application.ini application.ini is the application config file
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
;includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
alternatively, you can use a PHP array instead: #application.php
<?php return array( 'production' => array( 'bootstrap' => array( 'path' => APPLICATION_PATH . "/Bootstrap.php", 'class' => 'Bootstrap', ), ), );
#default controller In StarFramework, the default controller is named IndexController:
<?php class IndexController extends Star_Controller_Action { public function init() { } public function indexAction() { $this->view->assign(array( 'content' => 'Hello world.', )); $this->view->title = 'Hello world'; } } ?>
#view script The view script for default controller and default action is in the application/views/scripts/index/index.phtml, SF provides a simple view engineer called "Star_View", which supported the view template written by PHP.
<html> <head> <title><?php echo $this->title;?></title> </head> <body> <?php echo $this->content; ?> </body> </html>
#LICENSE
StarFramework is distributed under the terms of the MIT License.
版权声明:
1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。2、网站不提供资料下载,如需下载请到原作者页面进行下载。
3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考学习用!
4、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。