Exemplo n.º 1
0
 public function __construct($controller_name, $view_name)
 {
     $controller_name = str_replace("_", "/", $controller_name);
     $this->controller_name = $controller_name;
     $this->view_name = $view_name;
     $this->view_dir = Grug_Dispatch::getInstance()->base_dir . '/App/Views';
 }
Exemplo n.º 2
0
 static function getInstance($base_dir = '')
 {
     if (empty(self::$instance)) {
         self::$instance = new self($base_dir);
     }
     return self::$instance;
 }
Exemplo n.º 3
0
上面这种方式几乎不需要修改web服务器任何配置。
下面提供另一种链接访问方式:http://yourhost/test/thanks?p1=a&p2=b
这种方式需要修改web服务器配置文件,下面给出nginx.conf的配置
增加
	server {
		listen       80;
		server_name  yourhost;
		root         /var/www/html/mvc;
		# /var/www/html/mvc是你的文件目录,可修改为其他路径
		index  index.php index.html index.htm;
		try_files $uri $uri/ /index.php$is_args$args;
		location ~ \.php$ {
		 root           /var/www/html/mvc;
		 fastcgi_pass   127.0.0.1:9000;                                                                   
		 fastcgi_index  index.php;
		 fastcgi_param  SCRIPT_FILENAME  /var/www/html/mvc$fastcgi_script_name;
		 include        fastcgi_params;
		}
    }

公共底层可以放在Library里,文件命名与类名相同,但是请注意不要与Grug里文件名重复,以避免autoload时出错。
*/
// error_reporting(E_ERROR | E_WARNING | E_PARSE); //设置错误报告
ini_set('display_errors', 'On');
error_reporting(1);
define("BASEDIR", __DIR__);
include BASEDIR . "/Grug/Loader.php";
spl_autoload_register("\\Grug\\Grug_Loader::autoload");
Grug_Bootstrap::getInstance(BASEDIR)->init();
Grug_Dispatch::getInstance(BASEDIR)->dispatch();