Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how to load data from .env file in php

// You can use symfony/dotenv. First install it with composer
// with this command: composer require phpmailer/phpmailer

// Then add this in your code:
use SymfonyComponentDotenvDotenv;
require './vendor/autoload.php';

$dotenv = new Dotenv();
$dotenv->load(__DIR__.'/../.env'); // please update this path for your case

// You will get the variable both in
// $_ENV['ENVIRONMENT_VAR'] and $_SERVER['ENVIRONMENT_VAR'].
$password = $_SERVER['ENVIRONMENT_VAR'] ?? '';
Comment

PREVIOUS NEXT
Code Example
Php :: faker 
Php :: pdo bindparam string 
Php :: composer autoload psr-4 
Php :: PHP Max Input Vars 
Php :: How to install a specific version of package using Composer? 
Php :: console log in php 
Php :: php memory usage view 
Php :: Warning: mysqli_fetch_all() expects parameter 1 to be mysqli_result, bool given in C: ewxammphtdocslearnindex.php on line 11 
Php :: how to compare two versions in php 
Php :: how to get random element from a given array via php faker in laravel 
Php :: get name custom post type wordpress 
Php :: php $randomUA[rand(0, count($randomUA) 1) 
Php :: woocommerce get all subscriptions by user id 
Php :: count number of rows laravel controller 
Php :: laravel storage get file path 
Php :: update pdo mysql php 
Php :: php array size 
Php :: laravel log daily 
Php :: google translate api php 
Php :: laravel route group name 
Php :: start server cmd php 
Php :: php reduce 
Php :: Target class [Controller] does not exist. 
Php :: change returning datetime timezone to recalculate with user timezone laravel 
Php :: how to add property to an object in php 
Php :: check value falls between in two range in php 
Php :: array_unique multidimensional php 
Php :: upload webp to wordpress 
Php :: php cli display errors 
Php :: minus day from carbon date 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =