定制 percymamedy/laravel-dev-booter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

percymamedy/laravel-dev-booter

Composer 安装命令:

composer require percymamedy/laravel-dev-booter

包简介

Boost your Laravel app by registering Prod services only on Prod.

README 文档

README

Laravel dev booter

Latest Stable Version Latest Unstable Version License Total Downloads

Introduction

During development of a Laravel App; some Service Providers are very helpful. These services helps us with debugging and coding. But registering these providers on production is usually not a good idea. They can slow down our App or even expose sensitive information.

Laravel Dev Booter helps end this problem. The package consists of a single Service Provider. This provider will exclude unwanted providers from your production environment.

License

Laravel Dev Booter is open-sourced software licensed under the MIT license

Version Compatibility

Laravel DevBooter
5.x 0.2.x
6.x 1.0.x
7.x 2.0.x
8.x 3.0.x
9.x 3.0.x
10.x 4.0.x
11.x 5.0.x

Installation

Install Laravel Dev Booter as you would with any other dependency managed by Composer:

$ composer require percymamedy/laravel-dev-booter

Configuration

If you are using Laravel >= 5.5, you can skip service registration and aliases registration thanks to Laravel auto package discovery feature.

After installing Laravel Dev Booter all you need is to register the PercyMamedy\LaravelDevBooter\ServiceProvider in your config/app.php configuration file:

'providers' => [
    // Other service providers...

    PercyMamedy\LaravelDevBooter\ServiceProvider::class,
],

Usage

First use the vendor:publish command to copy the configuration file to your application:

$ php artisan vendor:publish --provider="PercyMamedy\LaravelDevBooter\ServiceProvider" --tag="config"

This will create the file config/dev-booter.php.

Defining your development environments

In the file config/dev-booter.php you will find the dev_environments section. Use this section to define your app's development environments:

'dev_environments' => [
    'local',
    'dev',
    'testing'
],

These are the only environments where Dev Booter will act; and try to register any Service providers.

Development Service providers locations

The next section in the config/dev-booter.php file is the dev_providers_config_keys. The array contains an entry for each of your development environments specified above. Feel free to add and edit this section.

'dev_providers_config_keys' => [
    'dev'     => ['app.dev_providers', 'app.local_providers'],
    'local'   => 'app.local_providers',
    'testing' => 'app.testing_providers',
]

The value for each of these entries can be an array or a string. The values represents the locations of a Service Provider array for each enviroment. You can even specify many locations for an environment, Dev Booter will take care of loading providers in each of these locations.

You may now define these Service Providers array in the config/app.php file as you would for any regular Service Provider:

'dev_providers' => [
    Foo\Bar\ServiceProvider::class,
],

'local_providers' => [
    Bar\Baz\ServiceProvider::class,
],

'testing_providers' => [
    Foo\Baz\ServiceProvider::class,
],

Development Aliases locations

The last section of the config/dev-booter.php file is the dev_aliases_config_keys. As with Service Providers, it works on the same principle.

You first specify the location of your aliases per environment:

'dev_aliases_config_keys' => [
    'dev'     => ['app.dev_aliases', 'app.local_aliases'],
    'local'   => 'app.local_aliases',
    'testing' => 'app.testing_aliases',
]

Then define these aliases array in the config/app.php file:

'dev_aliases' => [
    'Foo' => Foo\Bar\Facade::class,
],

'local_aliases' => [
    'Bar' => Bar\Baz\Facade::class,
],

'testing_aliases' => [
    'Baz' => Foo\Baz\Facade::class,
],

Going Further

In the above examples, providers and aliases array were define in config/app.php, but this does not have to be the case. You can define these array in any config files provided by Laravel or even create your own. Simply make sure you adjust your dev_providers_config_keys and dev_aliases_config_keys.

For example:

'dev_providers_config_keys' => [
    'dev' => ['app_dev.dev_providers', 'app_dev.local_providers'],
    // ...
]

Then in config/app_dev.php

'dev_providers' => [
    Foo\Bar\ServiceProvider::class,
],

'local_providers' => [
    Bar\Baz\ServiceProvider::class,
],

Credits

Big Thanks to all developers who worked hard to create something amazing!

Creator

Percy Mamedy

Twitter: @PercyMamedy
GitHub: percymamedy

percymamedy/laravel-dev-booter 适用场景与选型建议

percymamedy/laravel-dev-booter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 348.95k 次下载、GitHub Stars 达 35, 最近一次更新时间为 2016 年 10 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「laravel」 「dev-tools」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 percymamedy/laravel-dev-booter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 percymamedy/laravel-dev-booter 我们能提供哪些服务?
定制开发 / 二次开发

基于 percymamedy/laravel-dev-booter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 348.95k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 35
  • 点击次数: 24
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 35
  • Watchers: 1
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-10-08