PHP

Load encrypted .env files in PHP.

Package

dotenvx/phpdotenvx

Install

Use PIE for the native extension and Composer for the PHP package.

pie install dotenvx/phpdotenvx-ext
composer require dotenvx/phpdotenvx

Usage

Load the .env file alongside index.php before reading variables in your app.

<?php

require __DIR__ . '/vendor/autoload.php';

Dotenvx\Dotenvx::createImmutable(__DIR__)->safeLoad();

See the PHP quickstart for the full encryption workflow.

Open page ↗

Side path