Download the PHP package axy/env without Composer

On this page you can find all versions of the php package axy/env. 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 env

axy\env

Abstracting access to the environment (PHP).

Latest Stable Version Minimum PHP Version Build Status Coverage Status

Documentation

The library provides the abstract layer for access to the environment. The environment is

If some code has direct access to super-global arrays or calls functions like time() or header() then it code becomes tied to the environment. This code is difficult to test and configure.

The library provides the environment wrapper (an instance of axy\env\Env class). The application code gets this wrapper from the outside and works with the environment via it. By default the wrapper just delegates requests to standard functions. But this behaviour can be redefined (for test or an other purpose).

Example

By default will be used the standard environment and $this->env->getCurrentTime() returns the current time. But this behaviour can be changed.

Config

The environment wrapper with standard behaviour:

The non-standard behavior is specified in the config:

The config specified via an array (as above) or via an instance of axy\env\Config:

An array is simply, but the object supports autocomplete in IDE.

Specific parameters of the config are described in the relevant sections below.

Cloning

Current Time

Check the current time (returns a timestamp):

Parameter time specified the current time. It can be an int or a numeric string (timestamp) or a string for strtotime.

Changing time

$env->getCurrentTime() in the above example always returns the same time. For long-lived scenarios, the time change can be important.

If specified timeChanging then the time will be changing.

Custom function instead time()

If time is not specified getCurrentTime() calls a wrapper of the global function time() (see below section "Global Functions"). It can override.

Super-Globals

The super-globals arrays $_SERVER, $_ENV, $_GET, $_POST, $_REQUEST, $_COOKIE, $_FILES available via

Their can override in the config:

Global Functions

Magic __call delegates to global functions.

Overriding:

Checking the existence of functions $env->isFunctionExists(string $name):bool.

echo() can also be overridden.

Example

Function getallheaders() not exist in all environments.

Override:

Or

Functions list

It is intended for functions that access the environment. In phpdoc for autocomplete lists the following:

But theoretically it can be used for any function.

Streams

Access to php I/O streams.

Container $env->streams contains following object:

These objects implement interface IStream.

You can create object with the interface IStream and spoof a stream:

You can use classes Stream and StreamMock:

Stream is wrapper on a stream resource.

StreamMock

StreamMock is a wrapper on a string.

In addition to the methods of IStream, StreamMock supports following methods:

Factory

The method getStandard() returns an env wrapper for standard behaviour.

The method create($config) creates a wrapper with overriding behaviour. It can taken:

an array

a Config instance

or a Env instance itself

By default (NULL) specifies the standard wrapper.

The target service can take wrapper in different formats and not to deal with them.

Exceptions

The library can throw the following exceptions:


All versions of env with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
axy/errors Version ~1.0.2
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 axy/env contains the following files

Loading the files please wait ....