定制 phpexperts/laravel-env-polyfill 二次开发

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

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

phpexperts/laravel-env-polyfill

Composer 安装命令:

composer require phpexperts/laravel-env-polyfill

包简介

Use Laravel's pre-5.8 env() function in your non-Laravel projects.

README 文档

README

TravisCI Test Coverage

Benefits

  • Works with any package, even non-Laravel ones (it was my secondary reason)
  • You no longer have to fear Laravel just going one day "Oops! We're not going to read from the environment anymore! Too bad!" on a non-major release.

Backstory

With the introduction of Laravel 5.8, they broke the essential env() function by changing it from reading from/writing to environment variables to only using the global $_SERVER array, which is totally useless in console-based apps.

See

Therefore, I took it upon myself to create this polyfill to ensure that the pre-5.8 behaviors remain intact.

Additionally, this is a great little utility function to use outside of Laravel-specic projects that also want to use the env() function.

It is specially configured with a 0.0.1 composer vendor and a AAutoloadFirst namespace, so that composer will always load it before it gets to Laravel. See composer/composer#6768

The source code is lifted directly from the last version of Laravel 5.7.

As you can imagine, most of the copyright in this project belongs to Taylor Otwell, 2018.

It also includes 100% unit test code .

Installation

Via Composer

composer require phpexperts/laravel-env-polyfill

Usage

putenv('foo=bar');
$foo = \env('foo'); // 'bar'

and

if (in_array(SomeTrait::class, class_uses_recursive($this)) {
    // The class or its child it's being called from uses SomeTrait.
}

Use cases

PHPExperts\Laravel57EnvPolyfill\Tests\Env
✔ Env
✔ Env with quotes
✔ Env true
✔ Env false
✔ Env empty
✔ Env null
✔ Value
✔ Env will use default value if needed
✔ Will load vlucas/phpdot if a .env is present.
✔ Will not load vlucas/phpdotenv if a .env is not present.

Testing

phpunit

Contributors

Theodore R. Smith theodore@phpexperts.pro
GPG Fingerprint: 4BF8 2613 1C34 87AC D28F 2AD8 EB24 A91D D612 5690
CEO: PHP Experts, Inc.

Taylor Otwell

License

MIT license. Please see the license file for more information.

phpexperts/laravel-env-polyfill 适用场景与选型建议

phpexperts/laravel-env-polyfill 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 50.77k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2019 年 05 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 phpexperts/laravel-env-polyfill 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 50.77k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 13
  • 依赖项目数: 6
  • 推荐数: 3

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-05-10