-
Notifications
You must be signed in to change notification settings - Fork 0
Quick start
fkrzski edited this page Feb 1, 2022
·
2 revisions
composer require fkrzski/dotenv
"require": {
"fkrzski/dotenv": "^1.1",
},
Quick start only for newest version (Currently 1.1)
For use this package you must include autoload.php file from composer /vendor directory
// file.php
require "./vendor/autoload.php";
Nextly you must use Dotenv
class in your file.
// file.php
require "./vendor/autoload.php";
use fkrzski\Dotenv\Dotenv;
First you need to create a .env
file and put some variables in it
# .env file
FOO="bar"
BAR=foo
VAR=value
Then load variables from this file into your project
// file.php
require "./vendor/autoload.php";
use fkrzski\Dotenv\Dotenv;
$dotenv = new Dotenv('path\to\your\file\.env');
$dotenv->start();
echo getenv('FOO'); // Output: bar
echo $_SERVER['BAR']; // Output: foo
echo $_ENV['VAR']; // Output: value
Taht's all!