我独自走进 Laravel5.5 的❤(五)
上一节,我走完了bootstrap/app.php的表面,这一节我将走进app.php引入的Illuminate\Foundation\Application类,也就是laravel的核心。
1.
//引入php一个代表匿名函数的类
use Closure;
//引入一个用于报告只在应用运行的时候发生的错误的类
use RuntimeException;
//引入框架的数组类
use Illuminate\Support\Arr;
//引入框架的字符串类
use Illuminate\Support\Str;
//引入框架的http请求类
use Illuminate\Http\Request;
//引入框架的集合类
use Illuminate\Support\Collection;
//引入框架的容器类
use Illuminate\Container\Container;
//引入框架的文件系统类
use Illuminate\Filesystem\Filesystem;
//引入框架的日记服务提供者类
use Illuminate\Log\LogServiceProvider;
//引入框架的服务提供者类
use Illuminate\Support\ServiceProvider;
//引入框架的事件服务提供者类
use Illuminate\Events\EventServiceProvider;
//引入框架的路由服务提供者类
use Illuminate\Routing\RoutingServiceProvider;
//引入框架的http核心接口类
use Symfony\Component\HttpKernel\HttpKernelInterface;
//引入http错误类
use Symfony\Component\HttpKernel\Exception\HttpException;
//引入http核心契约类
use Illuminate\Contracts\Http\Kernel as HttpKernelContract;
//引入环境加载变量类
use Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables;
//引入http基础请求类
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
//引入http无法找到错误类
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
//引入契约容器
use Illuminate\Contracts\Foundation\Application as ApplicationContract;
解读:引入应用容器支持模块
2.class Application extends Container implements ApplicationContract, HttpKernelInterface
解读:应用容器类继承容器类并且实现容器契约,http核心接口
3.
/**
* The Laravel framework version.
* laravel框架版本号
* @var string
*/
const VERSION = '5.5.33';
/**
* The base path for the Laravel installation.
*laravel安装路径
* @var string
*/
protected $basePath;
/**
* Indicates if the application has been bootstrapped before.
*指出应用是否已经被启动过
* @var bool
*/
protected $hasBeenBootstrapped = false;
/**
* Indicates if the application has "booted".
*指出应用是否已经被启动过
* @var bool
*/
protected $booted = false;
/**
* The array of booting callbacks.
*启动中回调数组
* @var array
*/
protected $bootingCallbacks = [];
/**
* The array of booted callbacks.
*已经启动回调数组
* @var array
*/
protected $bootedCallbacks = [];
/**
* The array of terminating callbacks.
*终止回调数组
* @var array
*/
protected $terminatingCallbacks = [];
/**
* All of the registered service providers.
*所有已经注册的服务提供者数组
* @var array
*/
protected $serviceProviders = [];
/**
* The names of the loaded service providers.
*已经加载的服务提供者的名字数组
* @var array
*/
protected $loadedProviders = [];
/**
* The deferred services and their providers.
*被推迟的服务和他们的提供者
* @var array
*/
protected $deferredServices = [];
/**
* A custom callback used to configure Monolog.
*应用于monolog日记库环境配置的自定义回调
* @var callable|null
*/
protected $monologConfigurator;
/**
* The custom database path defined by the developer.
*开发者自定义的数据库路径
* @var string
*/
protected $databasePath;
/**
* The custom storage path defined by the developer.
*开发者自定义的储存路径
* @var string
*/
protected $storagePath;
/**
* The custom environment path defined by the developer.
*开发者自定义的环境路径
* @var string
*/
protected $environmentPath;
/**
* The environment file to load during bootstrapping.
*启动时加载的环境文件
* @var string
*/
protected $environmentFile = '.env';
/**
* The application namespace.
*应用的命名空间
* @var string
*/
protected $namespace;
解读:laravel的基础变量
4.
public function __construct($basePath = null)
{
if ($basePath) {
//如果根路径不为空,设置根路径为指定路径
$this->setBasePath($basePath);
}
//注册基础的绑定到容器中
$this->registerBaseBindings();
//注册所有服务提供者
$this->registerBaseServiceProviders();
//注册核心容器集合
$this->registerCoreContainerAliases();
}
解读:容器的注入
本作品采用《CC 协议》,转载必须注明作者和本文链接