Skip to content

Instantly share code, notes, and snippets.

@lozadaOmr
Last active August 29, 2015 14:17
Show Gist options
  • Save lozadaOmr/b1b411ef5db794601fa4 to your computer and use it in GitHub Desktop.
Save lozadaOmr/b1b411ef5db794601fa4 to your computer and use it in GitHub Desktop.
Alternative to storing pasword or other sensitve data

Question:

Should we include passwords (Database, SSH, etc) on our git repo.

Answer:

Yes, if you don't want to be changing this AKA consistent throughout every other dev.

No, because now everyone will know them

NOTE:

Even if you delete files on the repo. EX: Delete the password after accidentally commiting the password. This is bad practice.

Solution:

Use .env files and env variables

Example:

  • Create a .env.local.php
  • Store it in the root directory (Alongside app, bootstrap, public, vendor folder)

env.local.php

<?php
    return array(
        'PRODUCTION_HOST'     => 'makarios.cloudapp.net',
        'PRODUCTION_USERNAME' => 'admin',
        'PRODUCTION_PASS'     => '123456',
        'key'                 => '',
        'keyphrase'           => '',
        'PRODUCTION_ROOT'     => '/var/www/makarios',
    );

Add this to your .gitignore

Then you can call upon the values by using the keys returned by the array If you need the password you can just do: $_ENV['PRODUCTION_PASS']

Official Documentation:

Protecting Sensitive Configuration

http://laravel.com/docs/4.2/configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment