Laravel 配置(一)

          $this->showTitle("配置学习");
          $this->showTitle("简介");
          
          //获取配置选项
          $timezone = Config::get("app.timezone");
          $this->showLog($timezone);

          //如果配置选项不存在,可以返回默认的
          $path = Config::get("app.path", "__PATH__");
          $this->showLog($path);
          
          //为配置选项赋值
          //在程序运行时设置的配置值只在本次运行请求过程中有效,不会对以后的请求制成影响
          Config::set("app.timezone","PRC");
          $timezone = Config::get("app.timezone");
          $this->showLog($timezone);
          
          
          $this->showTitle("环境配置");
          //可以在不同的环境上运行不同的配置文件
          //在config目录下创建跟环境名同名的目录
          $mykey = Config::get("app.mykey");
          $this->showLog($mykey);
          
          $environment = App::environment();
          //var_dump($environment);
          //echo $environment;
          //后面两种不同环境获取配置文件的方法没测试成功
          
          $this->showTitle("维护模式");
          //维护模式
          //php artisan down   执行维护
          //php artisan up     停止维护
          //执行维护将启用app/start/global.php文件中的App::down()方法显示视图
          
          $this->showTitle("维护模式&队列");
          //现在还不太了解这里所说的队列是指正在发送的请求还是其它的

  

start.php

运行环境配置

//4.1 以后这里写的是计算机名,而不是域名了
//$env = $app->detectEnvironment(array(
//
//	//'local' => array('xlc-PC'),
//        //'production' => array('')
//));

//可以在调用detectEnvironment时传递一个闭包,就可以按照自己的方式检查环境了
$env = $app->detectEnvironment(function()
{
     //return $_SERVER['MY_LARAVEL_ENV'];
     return "test.com";
     //这个没弄懂
});

  

global.php

//执行维护模式将启用App::down()方法

App::down(function()
{
	return Response::make("进入维护模式!", 503);
        //可以另外为维护模式添加视图
        //return Response::view('maintenance', array(), 503);
});

  

 

posted @ 2014-02-12 00:07  简单--生活  阅读(292)  评论(0)    收藏  举报
简单--生活(CSDN)