Created
June 22, 2017 16:51
-
-
Save davidangel/c40456ca69f244809e2c00448c79b6e8 to your computer and use it in GitHub Desktop.
Azure Connection Config for use with Laravel
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 | |
$azureConnectionInfo = getenv("MYSQLCONNSTR_localdb"); | |
$connectionInfoEntries = preg_split('/;/', $azureConnectionInfo); | |
$connectionKeys = []; | |
array_walk($connectionInfoEntries, function ($entry) use (&$connectionKeys) { | |
list($name, $value) = preg_split("/=/", $entry); | |
$connectionKeys[$name] = $value; | |
}); | |
list($connectionKeys['host'],$connectionKeys['port']) = explode(':', $connectionKeys['Data Source']); | |
$connectionKeys['database'] = $connectionKeys['Database']; | |
$connectionKeys['username'] = $connectionKeys['User Id']; | |
$connectionKeys['password'] = $connectionKeys['Password']; | |
unset($connectionKeys['Data Source']); | |
unset($connectionKeys['Database']); | |
unset($connectionKeys['User Id']); | |
unset($connectionKeys['Password']); | |
return $connectionKeys; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment