Skip to content

Instantly share code, notes, and snippets.

@davidangel
Created June 22, 2017 16:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidangel/c40456ca69f244809e2c00448c79b6e8 to your computer and use it in GitHub Desktop.
Save davidangel/c40456ca69f244809e2c00448c79b6e8 to your computer and use it in GitHub Desktop.
Azure Connection Config for use with Laravel
<?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