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 (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2022-07-27 (3 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 57 All time: 10,246 This week: 180Up
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
Number 8
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
Age: 44
All time rank: 109370 in Germany Germany
Week rank: 287 Up9 in Germany Germany Up
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:57
This week:0
All time:10,246
This week:180Up