nathanlesage/envedit 问题修复 & 功能扩展

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

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

nathanlesage/envedit

Composer 安装命令:

composer require nathanlesage/envedit

包简介

A simple class for editing the .env-file in your project via PHP.

README 文档

README

A simple class for editing the .env-file in your project via PHP.

Why edit your .env-file via PHP?

Normally, the .env-file is used by developers to adapt to the current environment like production, develop, local, etc. To adapt to these environments, it is necessary to store different credentials (like database username and password, etc.) for different environments.

But if you are developing an app that relies on an .env-file and should be distributed to end users, you cannot assume they know which values for an .env-file are correct and which are not. Also, you might not want your end users to always ssh to your server to edit the file, but do it with a comfortable GUI. So this library enables you to easily read an .env-file, edit the values and re-write the file with the new variables.

Installation

You can install it easily via composer:

$ composer require nathanlesage/envedit

Usage

You only need to interact with the EnvEdit class. You may access your .env-file by passing its path to a new EnvEdit object:

use NathanLeSage\EnvEdit;

...

$editor = new EnvEdit('/path/to/your/.env');

// Read and parse the file

$editor->read();

// Retrieve the value of a specific variable.
// Of course, you should normally do this via env('APP_ENVIRONMENT')
// or similar.

$value = $editor->getValue('APP_ENVIRONMENT');

// Change one or more variables

$editor->setVars(
    ['APP_ENVIRONMENT' => 'production',
    'REDIS_HOST' => '123.321.12.32']
    );

// Write your changes to file

$editor->write();

// You could also retrieve the file's contents without writing them.
// This is useful for backup purposes or letting the user control what
// will be altered.

$editor->getFile();

Contribution

If you would like to contribute, just fork this library and send a pull request with your changes! I appreciate every help!

License

This library is licensed under the terms of the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-09-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固