Download the PHP package monolyth/envy without Composer

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

Monolyth/Envy

Flexible environment handler for PHP projects (including unit tests!)

When writing PHP projects that are more complicated than a two-page site, you're going to run into some real life problems:

Installation

Composer (recommended)

Manual

  1. Download or clone the repository;
  2. Add /path/to/envy/src for the namespace Monolyth\\Envy\\ to your autoloader.

Usage

As of version 0.7, Envy works exclusively on .env files, since that seems to be the industry standard. We do still, however, support some extensions.

To construct your environment (somewhere centrally), instantiate an object of the Monolyth\Envy\Environment class. It takes two parameters: the path to your environment configuration files, and a hash where the keys are environment names and the values are either booleans or callables returning a boolean. Any environment that is or resolves to false will be skipped. Hence, you could do something like this:

After initial instantiation you can either use dependency injection to access the environment, or you the static Environment::instance() method.

You can define as many environments as you want, since multiple can be valid at any given time. E.g. both prod and web or prod and cli.

Keep in mind that existing keys will be overwritten by subsequent environments defining the same key.

Configuration file naming

We're using .env format, so configuration files should be called either .env (for "generic" or "global" variables, the environment '' in other words) or alternatively .env.ENVIRONMENT_NAME. Note that these should not be included in your VCS! That's the whole idea of .env files. The only exception is a .env.example file with dummy values, but which gives other users a comprehensive list of stuff they would want to set.

Checking for environments

You'll often want to check for environments. All defined environments will be available on the $environment object as true, else false. So you can do something like the following:

Using defined environment variables

Like the environments themselves, variables are available as properties on the environment object, or will be false if undefined.

Usually (not sure if by convention or as an actual requirement...) environment variables are in UPPERCASE. This is ugly in PHP. Hence, all variables are lowercased for your convenience:

Custom feature: JSON support

For any value that can be json_decoded, its actual decoded value is used instead.

Custom feature: underscore object expansion

Okay, that's a crappy name. What this means is that for any variable names containing underscores, they are actually treated as "namespaces" and stored under sub-environments. Consider the following:

This would work, but is annoying. Envy automagically turns this into:

This works for as many levels of nesting as you'd need.

Placeholders

Default .env placeholders are supported, e.g.:

Gotchas and caveats

Note, however, the following is not a problem:

...since the JSON parsing won't be done until after the underscores have been expanded.

Differences from other DOTENV loaders


All versions of envy with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
m1/env Version ^2.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 monolyth/envy contains the following files

Loading the files please wait ....