alexoliverwd / dotenv-loader
Load environment variables into a PHP application
Installs: 992
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/alexoliverwd/dotenv-loader
Requires
- php: >=8.1
Requires (Dev)
- pestphp/pest: ^1.23
- phpstan/phpstan: ^1.6
This package is auto-updated.
Last update: 2025-10-08 00:00:00 UTC
README
Load configuration variables into your PHP application's global namespace from an .env file for flexible management across different environments.
Installation
composer require alexoliverwd/dotenv-loader
Basic Usage
\AOWD\envLoader\ResourceLoader::applyEnvironmentVariables(__DIR__ . '/.env');
Public Class Methods
loadResource
loadResource( string $resource_location ): array
The loadResource method retrieves key-value pairs from a configuration file, like /home/.env, providing a structured and flexible way to manage application settings across various environments.
applyEnvironmentVariables
applyEnvironmentVariables( string $resource_location ): void
The applyEnvironmentVariables method imports key-value pairs from a configuration file, like /home/.env, directly into PHP's global namespace, making them accessible throughout your application using the built-in $_ENV superglobal variable.
encryptEnvironmentVariables
encryptEnvironmentVariables( array $environment_variables, string $public_key_content ): array
The encryptEnvironmentVariables method encrypts the values of the key, value pair array using a provided public key.
decryptEnvironmentVariables
decryptEnvironmentVariables( array $environment_variables, string $private_key_content ): array
The decryptEnvironmentVariables method decrypts the values of the key, value pair array using a provided private key.