foodette / yii1-dotenv
YIi 1 phpdotenv extension
Installs: 1 167
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ^7.1.3
- vlucas/phpdotenv: ^2.5
- yiisoft/yii: ^1.1
Requires (Dev)
- phpunit/phpunit: ^7.4
This package is auto-updated.
Last update: 2024-10-29 05:17:09 UTC
README
PHP DotEnv for Yii 1.1 Framework.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist foodette/yii1-dotenv "*"
or add
"foodette/yii1-dotenv": "*"
to the require section of your composer.json
file.
Usage
Once the extension is installed, simply use the provided env()
function in your code :
[
'db' => [
'password' => env('DB_PASS'),
],
]
The env function will autoload .env file, it uses the following search mechanism :
If there is a Yii class the autoloader will try and detect `vendor` or `root` alias, otherwise
up to the project directory to determine dotenv path.
Best is to set the vendor
or root
alias before calling env()
function.
Yii::setPathOfAlias('root', 'PATH/TO/PROJECT/ROOT');