Download the PHP package opxcore/config-environment without Composer

On this page you can find all versions of the php package opxcore/config-environment. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package config-environment

Config environment loader

Build Status Coverage Status Latest Stable Version Total Downloads License

Installing

Important notice

All environment variables are stored in static property so any instance of environment would have access to the same set of environment variables.

Usage

where $path is directory where environment file is placed.

Loading environment

To load environment variables from file call $environment->load($filename), where $filename is a name of file. All variables would be stored locally, not affecting any of $_ENV, $_SERVER and so on.

Additional arguments is load($filename, $safe, $silent). If $safe is set to true variables would not be overwritten if they are already present. If $silent is set to true no exceptions would be thrown. Function returns true if environment file wss processed successfully, false in case of any errors.

Reading environment variables

$environment->get($key, $default) returns environment variable if it set, otherwise returns value assigned to default or return value of callable passed to as default.

$environment->has($key) returns true is environment variable set, false otherwise.

Manipulations

$environment->set($key, $value, $safe) sets value to environment. If $safe is set to true variables would not be overwritten if they are already present. Passed values of string type it would be parsed (see below), others would be set as is.

$environment->unset($key) removes variable from environment.

Format

Each line of environment must contain one value, consisting of variable name and its value separated by = sign. Other words, part of line before = sign would be used as variable name, another part would be value of variable.

For example:

Each value would be parsed according next rules:

String

Each quoted value would be converted to unquoted strings.

Result of $environment->get('DB_HOST') would be '127.0.0.1'.

Boolean

If value is true or false it would be converted to boolean type.

Null

Null values would set to null

Array

Arrays must start with [ and ends with ]. Items must be separated by commas. Each item would be parsed according this rules. Nested arrays are not supported.

Numbers

If value represents any of number format it would be converted to integer or float.

If parser would not recognise type of value, original string would be returned.

Result of $environment->get('APP_KEY') would be 'base64:0vqkPYSbwPm3MOzdxQJ76Ps6pouZRjN5xPx3b+dm628='.


All versions of config-environment with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4
opxcore/config-environment-interface Version ^1.0.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package opxcore/config-environment contains the following files

Loading the files please wait ....