定制 natanael-oliveira/dot-env 二次开发

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

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

natanael-oliveira/dot-env

最新稳定版本:v1.0.0

Composer 安装命令:

composer require natanael-oliveira/dot-env

包简介

A simple library to manage environment variables in PHP

README 文档

README

Simplifying Environment Variable Management.

Install

composer require natanael-oliveira/dot-env

Example of use

A new .env file will be created at the root of your project, you can manually insert your environment variables or define them dynamically using the set() method:

<?php

require 'vendor/autoload.php';
use NatanaelOliveira\DotEnv\Environment;

// Create an instance of the Environment class
$env = new Environment();

// Set the environment variables
$env->set('DB_HOST', 'host');
$env->set('DB_USER', 'user');
$env->set('DB_PASS', 'password');
$env->set('DB_PREFIX', 'db_prefix_');

// Get environment variables
$dbHost = $env->get('DB_HOST');
$dbUser = $env->get('DB_USER', 'default_user');
$dbPass = $env->get('DB_PASS');

// Remove environment variables
$env->remove('DB_PREFIX');

// Use environment variables in your application
echo "DB Host: $dbHost<br>";
echo "DB User: $dbUser<br>";
echo "DB Password: $dbPass<br>";

Requirements

This library needs PHP 7.4 or greater.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2023-09-26