ejetar/laravel-environment 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

ejetar/laravel-environment

Composer 安装命令:

composer require --dev ejetar/laravel-environment

包简介

📂 Load a custom .env file according to your environment.

README 文档

README

Table of Contents

About

Laravel Environment is a library designed to be used in conjunction with Laravel. It enables the user to load a different .env file from the original. The coolest thing about this library is that it provides different methods for you to do this.

There are currently 3 methods:

\Ejetar\LaravelEnvironment\LaravelEnvironment::fromSystemEnvironmentVariable($system_environment_variable_name, $default_value = 'local')
//Loads an environment file according to the value of a system environment variable
\Ejetar\LaravelEnvironment\LaravelEnvironment::fromFile($filename)
//Loads an environment file explicitly, stating the file path
\Ejetar\LaravelEnvironment\LaravelEnvironment::fromCustomMethod(Callable $callable)
//Enables the user to enter a custom method for loading the environment file

How it works

To use this library is very simple, just call Laravel Environment before return $app; in the bootstrap/app.php file:

...

\Ejetar\LaravelEnvironment\LaravelEnvironment::fromSystemEnvironmentVariable('MYAPP_ENV');

return $app;

Get started

Examples

From system environment variable method

First example

We assume in this example that the system environment variable MYAPP_ENV exists and has the value 'production'.

\Ejetar\LaravelEnvironment\LaravelEnvironment::fromSystemEnvironmentVariable('MYAPP_ENV');
//Will load the environment file .env.production
Second example

We assume in this example that the system environment variable MYAPP_ENV does not exist.

\Ejetar\LaravelEnvironment\LaravelEnvironment::fromSystemEnvironmentVariable('MYAPP_ENV');
//Will load the .env.local environment file. When the system environment variable does not exist, then it takes $default_value.
//By default $default_value is set to 'local'.
Third example

We assume in this example that the system environment variable MYAPP_ENV does not exist, and $default_value will be 'acme'.

\Ejetar\LaravelEnvironment\LaravelEnvironment::fromSystemEnvironmentVariable('MYAPP_ENV', 'acme');
//Will load the .env.acme environment file. When the system environment variable does not exist, then it takes $default_value.

From file method

First example
\Ejetar\LaravelEnvironment::fromFile('.env.local');
//Load the .env.local file explicitly

From custom method

First example

Loading the server IP-based environment file:

\Ejetar\LaravelEnvironment\LaravelEnvironment::fromCustomMethod(function(){
  switch($_SERVER['SERVER_ADDR']) {
    case '1.2.3.4':
      return '.env.local';
      break;
    case '5.6.7.8':
      return '.env.production';
      break;
    default: 
      return '.env.other';
  }
});

Installation

composer require ejetar/laravel-environment

Changelog

Nothing for now...

Contributing

Contribute to this wonderful project, it will be a pleasure to have you with us. Let's help the free software community. You are invited to incorporate new features, make corrections, report bugs, and any other form of support. Don't forget to star in this repository! 😀

License

This library is a open-source software licensed under the MIT license.

ejetar/laravel-environment 适用场景与选型建议

ejetar/laravel-environment 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 304 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 11 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-07