[李景山php]每天laravel[006]-vendor/laravel/framework/src/ILLuminate/Foundation/Application.php

本文档深入探讨了 `IlluminateFoundationApplication` 类,它是 Laravel 框架的基础。涉及内容包括命名空间、版本常量、受保护的属性、启动流程、回调函数、服务器支持、路径设置以及基础服务的注册。通过分析,可以了解到 Laravel 应用的初始化过程和关键组件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

namespace Illuminate\Foundation;
//命名空间:ILLuminate\Foundation; 照亮\基础;

加载:
闭包、运行时异常、数组、字符串、请求、容器、文件系统、服务支持、路由支持、http内核接口、http异常、Symfony请求、未发现http异常、应用合同

class Application 继承 Container 接口:ApplicationContract 及 HttpKernelInterface

// 定义了 版本常量
受保护的基础 变量 跟 java 相比 少了 int 类型 及 少了 $ 类型

受保护的 是否从beenBoostrapped 的方式
// 启动
数组 启动 回调

bootedCallbacks 启动后的 情况

这个 数组 终止 callbacks

服务器提供
$loaded 提供
deferred Services 服务器
数据库路径
存储路径
环境变量路径
环境变量文件名字
命名空间
传入的是 基础数据

// 归纳总结:
系统版本
基础路径
是否从bootstrap方式
启动
启动中回调
启动后回调
终止回调
服务器支持
加载支持
延迟服务
monolog配置
数据库基本路径
存储路径
环境路径
环境配置文件
命名空间

调用构造函数:
第一步:注册基本绑定
第二步:注册基本服务提供
第三步:注册内核容器别名
第四步:如果包含 基础路径, 设置基础路径。

<?php

namespace Illuminate\Foundation;// 命名空间

use Closure;// 闭包
use RuntimeException;// 运行时异常
use Illuminate\Support\Arr;// 数组支持
use Illuminate\Support\Str;// 字符串支持
use Illuminate\Http\Request;// 请求
use Illuminate\Container\Container; // 容器
use Illuminate\Filesystem\Filesystem;// 文件系统
use Illuminate\Support\ServiceProvider;// 服务器支持
use Illuminate\Events\EventServiceProvider;// 事件 服务 支持
use Illuminate\Routing\RoutingServiceProvider;// 路由 服务 支持
use Symfony\Component\HttpKernel\HttpKernelInterface;// http 内核 接口
use Symfony\Component\HttpKernel\Exception\HttpException;// http 异常
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;//Symfony 请求
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;// 未发现 http 异常
use Illuminate\Contracts\Foundation\Application as ApplicationContract;// 应用 合同

class Application extends Container implements ApplicationContract, HttpKernelInterface
{
    /**
     * The Laravel framework version.
     *
     * @var string
     */
    const VERSION = '5.2.22';

    /**
     * The base path for the Laravel installation.
     *
     * @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.
     *
     * @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 = null;

    /**
     * Create a new Illuminate application instance.
     *
     * @param  string|null  $basePath
     * @return void
     */
    public function __construct($basePath = null)
    {
        $this->registerBaseBindings();

        $this->registerBaseServiceProviders();

        $this->registerCoreContainerAliases();

        if ($basePath) {
            $this->setBasePath($basePath);
        }
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值