Last active
August 29, 2015 14:14
-
-
Save michaeldyrynda/9d5ca9143e9a175ec7a4 to your computer and use it in GitHub Desktop.
Easily swap out environment config in Laravel 5
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
function envswitch() { | |
if [ ! "$1" ] | |
then | |
echo "Missing required parameter envname" | |
echo "File should exist in current directory as .env.envname" | |
echo "Usage:" | |
echo " envswitch envname" | |
return | |
fi | |
ENV_PATH="./.env" | |
ENV_LINK=".env.$1" | |
# Ensure the file being sylinked exists | |
if [ ! -e "$ENV_LINK" ] | |
then | |
echo "Error: "$ENV_LINK" does not exist in current directory" | |
return | |
fi | |
# If the ENV_PATH already exists, remove it | |
if [ -e "$ENV_PATH" ] | |
then | |
rm -f "$ENV_PATH" | |
fi | |
# Symlink the file to $ENV_LINK | |
ln -s "$ENV_LINK" "$ENV_PATH" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment