PHP Classes

PHP Environment Variables Detection: Detect the current PHP environment variables

Recommend this page to a friend!
  Info   View files Documentation   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2022-07-27 (9 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 35 This week: 7All time: 10,513 This week: 32Up
Version License PHP version Categories
environment 1.0MIT/X Consortium ...5PHP 5, Configuration
Description Author

This package can detect the current PHP environment variables.

It can check a given directory or the current directory to find a dotenv (.env) file with configuration values specific to the current HTTP request host based on a list of possible environment setups.

The package can load the environment variables if it finds the dotenv file and initializes the system environment variables with the loaded values.

Innovation Award
PHP Programming Innovation award nominee
July 2022
Nominee
Vote
dotenv is a popular format used by many developers to store configuration values.

It is language-independent, so applications written in different languages can easily read the files written in that format.

Usually, dotenv files exist in a fixed location relative to the path of a project.

If you have multiple projects, you may need to find the path of the dotenv file to load the correct configuration file.

This package can test different paths and find the correct location based on a list of possible setups for your projects and the current HTTP host.

Manuel Lemos
Picture of Till Wehowski
  Performance   Level  
Name: Till Wehowski <contact>
Classes: 28 packages by
Country: Germany Germany
Innovation award
Innovation award
Nominee: 10x

Details

Environment

This is a environment library for quick environment setup. Forked from ahirarge/environment

Installation

To install through composer, simply put the following in your composer.json file:

{
    "require": {
        "frdl/environment": "*",
    }
}

Usage

index.php

$environment = new Frdlweb\Environment\Environment;
$environment->path('/')
            ->detectEnvironment([
                'local' =>[
                    'required' => true,
                    'hosts' => ['your-machine-name']
                ]
            ]);

index.php

$environment = new Frdlweb\Environment\Environment;
$environment->dir('/home/')
            ->detectEnvironment([
                'local' =>[
                    'required' => false,
                    'hosts' => ['your-machine-name']
                ]
            ]);

> You can check your machine name with hostname command.

.env.local.php

return [
        
        'secret-password' => 'secret-password-value'

    ];

.env.local.json

{
    "environment": "development"
}

$secret = getenv('secret-password');

Facades

If you wish, you can use environment library with facade connector. Please visit for guideline. ahir/facades

License

MIT

  Files folder image Files  
File Role Description
Files folder imagesrc (1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file readme.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imageFrdlweb (1 directory)

  Files folder image Files  /  src  /  Frdlweb  
File Role Description
Files folder imageEnvironment (1 file)

  Files folder image Files  /  src  /  Frdlweb  /  Environment  
File Role Description
  Accessible without login Plain text file Environment.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:35
This week:7
All time:10,513
This week:32Up
For more information send a message to info at phpclasses dot org.