Download the PHP package tofuma/env-exporter without Composer

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

ENV Exporter

A simple PHP package to generate .env files from example templates using system environment variables.

What does this package do?

When you deploy an application, you usually have a .env.example file with all the environment variable keys your application needs. The problem is: how do you generate the actual .env file with the correct values from your server environment?

This package solves that problem. It reads the keys from your .env.example file and creates a new .env file containing only the variables that exist in your system environment.

Why is this useful?

Requirements

How it works

  1. The package reads your .env.example file
  2. It extracts all the variable keys (for example: APP_NAME, DB_HOST, REDIS_URL)
  3. For each key, it checks if that variable exists in the system environment
  4. If the variable exists, it adds the key and value to the output
  5. It writes the result to your .env file

Supported formats in .env.example

The package understands these formats:

Installation

Usage

Option 1: Using the static method in PHP code

Option 2: Using the command line interface (CLI)

Output:

Real World Examples

Example 1: Simple deployment script

Example 2: Docker entrypoint script

In your docker-entrypoint.sh:

In your Dockerfile:

In your docker-compose.yml:

Example 3: Docker with run.sh script

Many projects use a run.sh script to start the application inside a Docker container. This is a common pattern for applications that need to do some setup before starting.

In your run.sh:

In your Dockerfile:

In your docker-compose.yml:

Example 4: Using with Dokploy

Dokploy is a deployment platform that allows you to set environment variables through its web interface. When you add environment variables in Dokploy, they become available as system environment variables in your container.

The problem: Dokploy (and similar platforms) may inject many system variables that you do not need. If you try to export all environment variables, you will get many unnecessary variables.

The solution: This package reads only the keys defined in your .env.example file. This means you only get the variables your application needs.

Step 1: In your Dokploy project, go to the "Environment" tab and add your variables:

Step 2: In your project, make sure you have a .env.example file with all the keys:

Step 3: Create a run.sh script in your project root:

Step 4: In your Dockerfile, use the run.sh script:

The package will create a .env file with only the variables defined in .env.example, using the values from Dokploy environment settings.

Example 5: Kubernetes deployment

In your Kubernetes deployment manifest:

In your container run.sh:

Example 6: GitHub Actions deployment

Example 7: Laravel Forge / Envoyer

In your deployment script:

License

MIT License. See LICENSE for more information.

Author

Created and maintained by tofuma.


All versions of env-exporter 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 tofuma/env-exporter contains the following files

Loading the files please wait ...