Download the PHP package datahihi1/tiny-env without Composer

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

TinyEnv

A simple environment variable loader for PHP applications. Designed for small projects, TinyEnv minimizes resource usage while ensuring stable performance. It loads environment variables from .env files and provides flexible methods to manage them.


Installation and Setup

Install via Composer

Installation is straightforward with Composer:

Or manually add it to your composer.json:

Run composer install or composer update to download the package.

1. load() - Basic Setup

After installing, include Composer's autoloader, create a TinyEnv instance, and load the environment variables:

2. Fast Load Option

Use the fastLoad option in the constructor to load variables immediately:

3. lazy() - Lazy Load Option

Load only variables matching specific prefixes:

4. only() - Load Only Specific Variables

Load only the specified environment variables by key (single or array):


Usage

TinyEnv provides simple methods and helper functions to work with environment variables. Below are examples based on a sample .env file:

1. env() - Retrieve Environment Variables

Use the global env() function to get environment variables:

2. setenv() - Set or Update Variables

Use setenv() to dynamically set or update environment variables. If file writing is enabled (default), it also updates the .env file:

Note: To disable file writing, use TinyEnv::setAllowFileWrites(false).

3. validate_env() - Validate Variables

Ensure variables meet specific rules (e.g., required, int, bool, string):

4. unload() - Clear Variables

Remove all loaded environment variables from $_ENV and the internal cache:

5. refresh() - Reload Variables

Clear current variables and reload from the .env file:


Example .env File

Create a .env file in your project root:

Full Example

Notes

Variable Interpolation

TinyEnv supports variable interpolation within .env values. You can reference other variables using ${VAR_NAME} syntax, and TinyEnv will automatically replace them with their corresponding values when loading:

In this example, DB_URL will be set to localhost:3306. Interpolation works recursively and supports any variable defined earlier in the file or already loaded into the environment.

Note: If a referenced variable is not defined, it will be replaced with an empty string.


All versions of tiny-env with dependencies

PHP Build Version
Package Version
Requires php Version >=7.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 datahihi1/tiny-env contains the following files

Loading the files please wait ....