Created
August 14, 2012 23:43
-
-
Save larzconwell/3353920 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Get the "API_SECRET" variable from our shell session | |
$api_secret = getenv('API_SECRET'); | |
// Same as above, but using a Superglobal | |
$api_secret = $_ENV['API_SECRET']; | |
// You can use phpinfo to show all the environmental variables you can use. | |
phpinfo(INFO_ENVIRONMENT); | |
/* | |
To set environmental variables you can do: | |
Linux/BSD: | |
API_SECRET=SOMESUPERSECRETKEYHERE | |
Note: you may need to export the key by prepending `export` to the above | |
Windows: | |
set API_SECRET=SOMESUPRTSECRETKEYHERE | |
*/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Once you do this, you don't have to worry about pushing secret keys to Git, you just have to create the environmental variables in the same shell session as when you run the script.