PHPackages                             kimbee-team/dotenv-dump - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kimbee-team/dotenv-dump

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

kimbee-team/dotenv-dump
=======================

Dumps environment variables from `.env` to `.htaccess` or plain PHP-file.

1.0.0(7y ago)0169MITPHPPHP ^5.5.9|&gt;=7.0.8

Since Jul 15Pushed 7y ago1 watchersCompare

[ Source](https://github.com/KimbeeTeam/dotenv-dump)[ Packagist](https://packagist.org/packages/kimbee-team/dotenv-dump)[ RSS](/packages/kimbee-team-dotenv-dump/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (2)Used By (0)

DotEnvDumpBundle
================

[](#dotenvdumpbundle)

The `DotEnvDumpBundle` parses`.env` files via [DotEnv](https://github.com/symfony/dotenv) and export environment variables in `.htaccess` (SetEnv directive) or `.php` (return array) formats.

The main purpose of this bundle to use it as a part of a deploy process for a shared hosting where you can't edit environment variables.

During development, you'll use the `.env` file to configure your environment variables. On your production server, it is recommended to configure these at the web server level.

So if you're using Apache, you can pass these variables via SetEnv directive in `.htaccess` file.

Or you can just cache them into `.env.php` file and replace in your front controller (index.php):

```
(new Dotenv())->load(__DIR__.'/../.env');
```

with something like

```
if (file_exists(__DIR__.'/../.env.php')) {
   $variables = require_once __DIR__.'/../.env.php';
   (new Dotenv())->populate($variables);
}
```

Usage
-----

[](#usage)

```
bin/console dotenv:dump [--htaccess] [--php] [path-to-output-file] [path-to-env-file]
```

Invoked with no parameters will export to `.htaccess` in the `%kernel.project_dir%`.

It's a safe to invoke command few times in a row.

Example
-------

[](#example)

`bin/console dotenv:dump --htaccess .htaccess ` will prepend (or replace if already exists) in the `.htaccess` following content:

```
###> .env ###
SetEnv "APP_ENV" "dev"
SetEnv "APP_SECRET" "6d15395b9c94f12f97fa31edc9c0c6f0"
###< .env ###
```

`bin/console dotenv:dump --php .env.php ` will rewrite `.env.php` file with the following content:

```
