8 Star 12 Fork 5

成武 / cnComment Laravel 4

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
start.php 8.94 KB
一键复制 编辑 原始数据 按行查看 历史
成武 提交于 2013-11-26 17:08 . 补充说明配置文件的加载方式
<?php
/*
|--------------------------------------------------------------------------
| Set PHP Error Reporting Options
|--------------------------------------------------------------------------
|
| Here we will set the strictest error reporting options, and also turn
| off PHP's error reporting, since all errors will be handled by the
| framework and we don't want any output leaking back to the user.
|
*/
// 关闭原生 PHP 错误报告,防止系统信息泄露
error_reporting(-1);
/*
|--------------------------------------------------------------------------
| Check Extensions
|--------------------------------------------------------------------------
|
| Laravel requires a few extensions to function. Here we will check the
| loaded extensions to make sure they are present. If not we'll just
| bail from here. Otherwise, Composer will crazily fall back code.
|
*/
// 检测 PHP 是否开启 mcrypt 拓展
if ( ! extension_loaded('mcrypt'))
{
die('Laravel requires the Mcrypt PHP extension.'.PHP_EOL);
exit(1);
}
/*
|--------------------------------------------------------------------------
| Register Class Imports
|--------------------------------------------------------------------------
|
| Here we will just import a few classes that we need during the booting
| of the framework. These are mainly classes that involve loading the
| config files for this application, such as the config repository.
|
*/
// 注册相关类的别名引用
use Illuminate\Http\Request;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Facade;
use Illuminate\Foundation\AliasLoader;
use Illuminate\Config\Repository as Config;
/*
|--------------------------------------------------------------------------
| Bind The Application In The Container
|--------------------------------------------------------------------------
|
| This may look strange, but we actually want to bind the app into itself
| in case we need to Facade test an application. This will allow us to
| resolve the "app" key out of this container for this app's facade.
|
*/
// 绑定应用程序实例到一个 Ioc 容器
$app->instance('app', $app);
/*
|--------------------------------------------------------------------------
| Check For The Test Environment
|--------------------------------------------------------------------------
|
| If the "unitTesting" variable is set, it means we are running the unit
| tests for the application and should override this environment here
| so we use the right configuration. The flag gets set by TestCase.
|
*/
// 检测是否处于测试环境中
if (isset($unitTesting))
{
$app['env'] = $env = $testEnvironment;
}
/*
|--------------------------------------------------------------------------
| Load The Illuminate Facades
|--------------------------------------------------------------------------
|
| The facades provide a terser static interface over the various parts
| of the application, allowing their methods to be accessed through
| a mixtures of magic methods and facade derivatives. It's slick.
|
*/
// 清除所有 Facade 实例
Facade::clearResolvedInstances();
// 设置应用程序 Facade 实例
Facade::setFacadeApplication($app);
/*
|--------------------------------------------------------------------------
| Register The Configuration Repository
|--------------------------------------------------------------------------
|
| The configuration repository is used to lazily load in the options for
| this application from the configuration files. The files are easily
| separated by their concerns so they do not become really crowded.
|
*/
// 绑定 Config 实例到一个 Ioc 容器
// 在这一步注册了配置文件目录 app_path('config')
// 注意:配置文件是按需加载的,仅在首次使用某配置时才载入相应配置文件
$config = new Config($app->getConfigLoader(), $env);
$app->instance('config', $config);
/*
|--------------------------------------------------------------------------
| Register Application Exception Handling
|--------------------------------------------------------------------------
|
| We will go ahead and register the application exception handling here
| which will provide a great output of exception details and a stack
| trace in the case of exceptions while an application is running.
|
*/
// 注册应用程序异常处理
$app->startExceptionHandling();
if ($env != 'testing') ini_set('display_errors', 'Off');
/*
|--------------------------------------------------------------------------
| Set The Console Request If Necessary
|--------------------------------------------------------------------------
|
| If we're running in a console context, we won't have a host on this
| request so we'll need to re-bind a new request with a URL from a
| configuration file. This will help the URL generator generate.
|
*/
// 若应用程序是在控制台中执行,则设置控制台请求
if ($app->runningInConsole())
{
$app->setRequestForConsoleEnvironment();
}
/*
|--------------------------------------------------------------------------
| Set The Default Timezone
|--------------------------------------------------------------------------
|
| Here we will set the default timezone for PHP. PHP is notoriously mean
| if the timezone is not explicitly set. This will be used by each of
| the PHP date and date-time functions throughout the application.
|
*/
// 获取 app/config/app.php 配置文件内容
$config = $app['config']['app'];
// 设置默认时区
date_default_timezone_set($config['timezone']);
/*
|--------------------------------------------------------------------------
| Register The Alias Loader
|--------------------------------------------------------------------------
|
| The alias loader is responsible for lazy loading the class aliases setup
| for the application. We will only register it if the "config" service
| is bound in the application since it contains the alias definitions.
|
*/
// 注册别名导入
AliasLoader::getInstance($config['aliases'])->register();
/*
|--------------------------------------------------------------------------
| Enable HTTP Method Override
|--------------------------------------------------------------------------
|
| Next we will tell the request class to allow HTTP method overriding
| since we use this to simulate PUT and DELETE requests from forms
| as they are not currently supported by plain HTML form setups.
|
*/
// 启用 HTTP 方法覆盖,以支持 PUT 和 DELETE 表单请求
Request::enableHttpMethodParameterOverride();
/*
|--------------------------------------------------------------------------
| Register The Core Service Providers
|--------------------------------------------------------------------------
|
| The Illuminate core service providers register all of the core pieces
| of the Illuminate framework including session, caching, encryption
| and more. It's simply a convenient wrapper for the registration.
|
*/
// 注册核心服务提供商
$providers = $config['providers'];
$app->getProviderRepository()->load($app, $providers);
/*
|--------------------------------------------------------------------------
| Boot The Application
|--------------------------------------------------------------------------
|
| Before we handle the requests we need to make sure the application has
| been booted up. The boot process will call the "boot" method on all
| service provider giving all a chance to register their overrides.
|
*/
// 启动应用程序,注册所有 provider 的 boot 方法
$app->boot();
/*
|--------------------------------------------------------------------------
| Load The Application Start Script
|--------------------------------------------------------------------------
|
| The start script gives us the application the opportunity to override
| any of the existing IoC bindings, as well as register its own new
| bindings for things like repositories, etc. We'll load it here.
|
*/
// 载入全局启动文件 app/start/global.php
$path = $app['path'].'/start/global.php';
if (file_exists($path)) require $path;
/*
|--------------------------------------------------------------------------
| Load The Environment Start Script
|--------------------------------------------------------------------------
|
| The environment start script is only loaded if it exists for the app
| environment currently active, which allows some actions to happen
| in one environment while not in the other, keeping things clean.
|
*/
// 载入运行环境启动文件 app/start/{$env}.php
$path = $app['path']."/start/{$env}.php";
if (file_exists($path)) require $path;
/*
|--------------------------------------------------------------------------
| Load The Application Routes
|--------------------------------------------------------------------------
|
| The Application routes are kept separate from the application starting
| just to keep the file a little cleaner. We'll go ahead and load in
| all of the routes now and return the application to the callers.
|
*/
// 载入路由文件 app/routes.php
if (file_exists($path = $app['path'].'/routes.php'))
{
require $path;
}
PHP
1
https://gitee.com/chengwu/cnComment-Laravel-4.git
git@gitee.com:chengwu/cnComment-Laravel-4.git
chengwu
cnComment-Laravel-4
cnComment Laravel 4
master

搜索帮助