[笔记][laravel]安装拓展包

说明

我们都知道 Laravel 扩展包的注册会对应用造成消耗。有一些扩展包是开发环境中专用,生产环境中并不会使用到,为了避免无用的负载, 必须严格控制其安装和加载。


安装

安装开发专用扩展包时 必须 使用 --dev 参数,如:

composer require laracasts/generators --dev

加载

开发专用的 provider 绝不config/app.php 里面注册,必须app/Providers/AppServiceProvider.php 文件中使用如以下方式:

public function register()
{
    if ($this->app->environment() == 'local') {
        $this->app->register('Laracasts\Generators\GeneratorsServiceProvider');
    }
}

转载自:https://laravel-china.org/docs/laravel-specification/5.5/development-specific-extensions-package/513

若有侵权,请务必通过邮箱与我联系

作者: 7gugu

I'm a phper!

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注