Skip to content

Instantly share code, notes, and snippets.

@Stormix
Created July 18, 2017 18:43
Show Gist options
  • Save Stormix/373496a07eef7e11810e95ab2e7dd652 to your computer and use it in GitHub Desktop.
Save Stormix/373496a07eef7e11810e95ab2e7dd652 to your computer and use it in GitHub Desktop.
A .env example for the php library PHP dotenv
// .env example
DATABASE_NAME=""
DATABASE_USER=""
DATABASE_PASS=""
SECRET_KEY="souper_seekret_key"
// Example.php You project file
<?php
require 'vendor/autoload.php';
$dotenv = new Dotenv\Dotenv(__DIR__);
$dotenv->load();
// Accessing the .env file variables
$dbname = getenv('DATABASE_NAME');
$dbname = $_ENV['DATABASE_NAME'];
$dbname = $_SERVER['DATABASE_NAME'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment