2017 © Pedro Peláez
 

symfony-bundle dotenv-dump

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

image

kimbee-team/dotenv-dump

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

  • Sunday, July 15, 2018
  • by waitxd
  • Repository
  • 1 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

DotEnvDumpBundle

The DotEnvDumpBundle parses.env files via DotEnv and export environment variables in .htaccess (SetEnv directive) or .php (return array) formats., (*1)

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., (*2)

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., (*3)

So if you're using Apache, you can pass these variables via SetEnv directive in .htaccess file., (*4)

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

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

with something like, (*6)

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

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%., (*7)

It's a safe to invoke command few times in a row., (*8)

Example

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

###> .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:, (*10)

<?php return array (
  'APP_ENV' => 'dev',
  'APP_SECRET' => '6d15395b9c94f12f97fa31edc9c0c6f0',
);

Installation

Applications that use Symfony Flex, (*11)

Open a command console, enter your project directory and execute:, (*12)

$ composer require kimbee-team/dotenv-dump

Applications that don't use Symfony Flex

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:, (*13)

$ composer require kimbee-team/dotenv-dump

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*14)

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:, (*15)

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new \KimbeeTeam\DotenvDump\KimbeeTeamDotenvDumpBundle(),
        );

        // ...
    }

    // ...
}

License

This bundle is released under the MIT license, (*16)

The Versions

15/07 2018

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

 

by wait

15/07 2018

1.0.0

1.0.0.0

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

  Sources   Download

MIT

The Requires

 

by wait