boomdraw/laravel-dotenv 问题修复 & 功能扩展

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

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

boomdraw/laravel-dotenv

Composer 安装命令:

composer require boomdraw/laravel-dotenv

包简介

Laravel dotenv manager

README 文档

README

The package that allows read and write .env file variables

Installation

Via Composer

composer require boomdraw/laravel-dotenv

The package will automatically register itself.

You can publish the config file with:

php artisan vendor:publish --provider="Boomdraw\Dotenv\DotenvServiceProvider" --tag="config"

Usage and methods

use Dotenv;
//or
use Boomdraw\Dotenv\Facades\Dotenv;
//or
use Boomdraw\Dotenv\Contracts\DotenvContract;

class Controller
{
    /**
     * @var \Boomdraw\Dotenv\Repositories\DotenvRepository
     */
    protected $dotenv;

    public function __construct(DotenvContract $dotenv)
    {
        $this->dotenv = $dotenv;
    }
}

all

Dotenv::all(): Collection

The function returns all .env vars as an \Illuminate\Support\Collection object.

set

Dotenv::set($key, ?string $value = null): self

The function writes the .env variable regardless of the variable existence.

Dotenv::setEmpty($key, ?string $value = null): self

The function writes the .env variable if it does not exist or empty.

add

Dotenv::add($key, ?string $value = null): self

The function adds the .env variable if does not exist.

put

Dotenv::put($key, ?string $value = null): self

The function updates .env variable if it exists.

Dotenv::putEmpty($key, ?string $value = null): self

The function updates .env variable if it exists and empty.

delete

Dotenv::delete($key): self

The function deletes .env variable.

An array of keys to delete can be passed as $key variable.

Setters features

You can pass data as an array for setters (set, add, put):

Dotenv::set['key1' => 'value1', 'key2' => 'value2']

Setters transform variable name removing quotes (', "), replacing spaces ( ) and hyphens (-) with an underscore (_) and transforming name to uppercase.

For example Dotenv::set('foo bar', 'baz') will write FOO_BAR=baz to .env file.

All setters and delete will rewrite .env file immediately.

reload

Dotenv::reload(): self

The function reloads .env file from the filesystem.

Collection methods

You can call all of Collection methods. For example:

Dotenv::get('APP_NAME') returns APP_NAME value.

Dotenv::has('APP_NAME') checks APP_NAME variable existence.

All collection methods are called for Dotenv collection copy, so any changes to collection will not affect .env file and Dotenv content.

Testing

You can run the tests with:

composer test

Security

If you discover any security related issues, please email pkgsecurity@boomdraw.com instead of using the issue tracker.

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-08-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固