定制 crasivo/bitrix-dotenv 二次开发

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

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

crasivo/bitrix-dotenv

最新稳定版本:0.0.2

Composer 安装命令:

composer require crasivo/bitrix-dotenv

包简介

Dotenv library adapter for 1C-Bitrix

README 文档

README

Adapter for the popular Dotenv library for 1C-Bitrix & Bitrix24.

Implementation features:

  • Simple and quick integration into an existing project
  • Formatting of scalar values

Minimum requirements for installation:

  • 1C-Bitrix kernel version (main): v20.5.400
  • PHP version: v7.2
  • Dotenv version: v5.0

🚀 Quick Start

To use the library (adapter), simply install the Composer package via the command:

$ cd /path/to/project
$ composer require crasivo/bitrix-dotenv

It is initially assumed that autoload.php is already connected to your project. If this is not the case, you can add it to one of the following files:

  • /bitrix/.settings.php
  • /bitrix/.settings_extra.php
  • /local/php_interface/init.php

Next, you need to initialize the EnvLocator service (similar to the standard one) and load the environment variables. Below is an example of initializing and loading environment variables.

// document root
Crasivo\Bitrix\Dotenv\EnvLocator::getInstance()->load();
// specified dir
Crasivo\Bitrix\Dotenv\EnvLocator::getInstance()->load('/path/to/another/dir');

Access to values is via EnvLocator or via the helper function env. Below are examples of working with environment variables.

$envLocator = Crasivo\Bitrix\Dotenv\EnvLocator::getInstance();
echo $envLocator->get('LOG_LEVEL', 'debug'); // 'debug' (string)
echo $envLocator->get('APP_DEBUG', false); // true (bool)
echo $envLocator->get('SOME_INTEGER_PARAM'); // 415454 (integer)
echo $envLocator->get('SOME_FLOAT_PARAM'); // 154.69 (float)

Via the helper function:

echo env('LOG_LEVEL', 'debug'); // 'debug' (string)
echo env('APP_DEBUG', false); // true (bool)
echo env('SOME_INTEGER_PARAM'); // 415454 (integer)
echo env('SOME_FLOAT_PARAM'); // 154.69 (float)

📜 License

This project is distributed under the MIT license. The full text of the license can be read in the corresponding file.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-11