Last active
September 1, 2016 08:04
-
-
Save coreymcmahon/d50fc25bf694c0e6932ac7d258b21fd1 to your computer and use it in GitHub Desktop.
Explode a resource identifier into its component parts
This file contains hidden or 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 | |
/** | |
* Parses resource identifiers of the format: | |
* RESOURCE=s3://username:password@domain/resource | |
*/ | |
if ($resource = getenv('RESOURCE')) { | |
// strip off the namespace, assume it's not needed (e.g 's3', 'mysql') | |
$identifier = explode('://', $resource)[1]; | |
list($credentials, $resource) = explode('@', $identifier); | |
list($username, $password) = explode(':', $credentials); | |
list($domain, $relative) = explode('/', $resource); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment