Skip to content

Latest commit

 

History

History

php

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

PHP Dotenv

For using it in PHP first you have to have:

  1. A PHP version installed.

  2. Installed the php-dotenv package. If you have composer installed you can do it just by running composer require vlucas/phpdotenv.

For a .env file like this:

<?php
  require("vendor/autoload.php");
  $dotenv = Dotenv\Dotenv::createUnsafeImmutable(__DIR__);

  $dotenv -> load(".env");

  $DB_NAME = $_ENV['DB_NAME'];
  echo $DB_NAME . "\n";
?>