Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aoliverwd/dotenv-loader
Load environment variables in PHP applications
https://github.com/aoliverwd/dotenv-loader
Last synced: 22 days ago
JSON representation
Load environment variables in PHP applications
- Host: GitHub
- URL: https://github.com/aoliverwd/dotenv-loader
- Owner: aoliverwd
- License: mit
- Created: 2022-05-22T09:18:03.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-14T23:27:51.000Z (10 months ago)
- Last Synced: 2024-03-14T22:22:50.935Z (9 months ago)
- Language: PHP
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Environment Variables Loader
Load configuration variables into your PHP application's global namespace from an `.env` file for flexible management across different environments.
## Installation```bash
composer require alexoliverwd/dotenv-loader
```## Basic Usage
```php
\AOWD\envLoader\ResourceLoader::applyEnvironmentVariables(__DIR__ . '/.env');
```## Public Class Methods
### loadResource
```php
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```php
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](https://www.php.net/manual/en/reserved.variables.environment).
### encryptEnvironmentVariables```php
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```php
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.