indextank/yii2-plugin-env
Composer 安装命令:
composer require indextank/yii2-plugin-env
包简介
PHP DotEnv for Yii2 framework
关键字:
README 文档
README
Yii 2 框架添加.env功能,实现类似于Lavaral框架中的.env功能。使框架配置更简单,更利于维护。本项目基于yiithings/yii2-dotenv。
本项目内含2个全局调试方法: p()和dd(),替代echo()、print_r()等输出函数;
p($a, $b):打印变量,支持数组,格式化显示,不中断打印后续的输出,类似于:echo "<pre>";print_r($a);echo "----";print_r($b);
dd($a):打印变量,支持数组,格式化显示,中断打印后续的输出,类似于:echo "<pre>";print_r($A);exit()
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist indextank/yii2-plugin-env "*"
or add
"indextank/yii2-plugin-env": "*"
to the require section of your composer.json file.
Usage
Once the extension is installed, simply use it in your code by :
[
'db' => [
'password' => penv('DB_PASS'),
],
]
The env function will autoload .env file, it uses the following search mechanism:
If there is a Yii class, then pass the alias @vendor or @app or @yii, Otherwise
according to the project directory to determine.
But, if your application vendor directory is a symbol link and you no registered @vendor or @app alias before call env function, the project will not working. So you should set the @vendor alias before calling env function.
统计信息
- 总下载量: 89
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-10-10