在laravel加载完vendor全局的类名=>路径对应之后,会加载一些必须加载的基础类和函数:如下

public static $files = array (

'1d1b89d124cc9cb8219922c9d5569199' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest.php',

'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',

'667aeda72477189d0494fecd327c3641' => __DIR__ . '/..' . '/symfony/var-dumper/Resources/functions/dump.php',

'bd9634f2d41831496de0d3dfe4c94881' => __DIR__ . '/..' . '/symfony/polyfill-php56/bootstrap.php',

'2c102faa651ef8ea5874edb585946bce' => __DIR__ . '/..' . '/swiftmailer/swiftmailer/lib/swift_required.php',

'e7223560d890eab89cda23685e711e2c' => __DIR__ . '/..' . '/psy/psysh/src/Psy/functions.php',

'5255c38a0faeba867671b61dfda6d864' => __DIR__ . '/..' . '/paragonie/random_compat/lib/random.php',

'f0906e6318348a765ffb6eb24e0d0938' => __DIR__ . '/..' . '/laravel/framework/src/Illuminate/Foundation/helpers.php',

'58571171fd5812e6e447dce228f52f4d' => __DIR__ . '/..' . '/laravel/framework/src/Illuminate/Support/helpers.php',

);

    第一个:hamcrest/Hamcrest.php 看代码是2009-2010写的一些辅助方法,如下图,整个文件都是自定义的一些数组处理等方法:

    第二个:symfony/polyfill-mbstring/bootstrap.php,这个一看就知道,如果没有mb_string扩展,laravel会加载php版的mb_string类库文件。

    第三个:functions/dump.php 类是一个测试打印输出类,它可以根据当前是WEB请求还是命令行执行以显示结果,展示的界面比较好看,比如显示最上面的数组时会在浏览器上展示:

第四个:polyfill-php56/bootstrap.php 检测当前的版本值,被php5.6里新增的函数:hash_equals,ldap_escape 以及php5.5.9里的函数gzopen,gzseek,gztell等。 第五个:swift_required.php 发邮件的类 第六个:Psy/functions.php 也是一些扩展函数 第七个:random_compat/lib/random.php  此为PHP 7的random_* API 扩展php程序。 第八个:Foundation/helpers.php 框架的全局函数,比如:base_path,abort等全局方法 第九个:Support/helpers.php 一些增加的扩展函数。比如array_prepend,array_last等,多是数组辅助函数。

    以上就是laravel初始化vendor后立即加载运行的一些函数、类、方法。执行完此步后在bootstrap/autoload.php中会执行:

//加载框架压缩文件,类似一些框架的runtime.php

$compiledPath = __DIR__.'/cache/compiled.php';

if (file_exists($compiledPath)) {

require $compiledPath;

}

compiled.php文件是一个将所有的加载压缩到一起的文件,这样可以加快运行速度。

精彩链接

评论可见,请评论后查看内容,谢谢!!!评论后请刷新页面。