PHP Classes

PHP Environment Variables Detection: Detect the current PHP environment variables

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 63 All time: 10,433 This week: 64Up
Version License PHP version Categories
environment 1.0MIT/X Consortium ...5PHP 5, Configuration
Description 

Authors

Ahir Ar-Ge
Özgür Adem I??kl?
Till Wehowski


Contributor

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 Melanie Wehowski
  Performance   Level  
Name: Melanie Wehowski <contact>
Classes: 30 packages by
Country: Germany Germany
Innovation award
Innovation award
Nominee: 12x

Documentation

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 (3)  
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 (3)  /  src  
File Role Description
Files folder imageFrdlweb (1 directory)

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

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

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:63
This week:0
All time:10,433
This week:64Up