Skip to content

Instantly share code, notes, and snippets.

@jamesmills
Last active June 11, 2019 04:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesmills/33a07546e1ff5cbe838fe53d3f3c2190 to your computer and use it in GitHub Desktop.
Save jamesmills/33a07546e1ff5cbe838fe53d3f3c2190 to your computer and use it in GitHub Desktop.
<?php
if (!function_exists('applicationUrl')) {
/**
* Will return the fully qualified domain name for the correct environment etc
*
* @param string $sub_domain
* @param string $path
* @return string
*/
function applicationUrl($sub_domain = 'app', $path = null)
{
$related_link = parse_url(config('app.url'));
$final_url = $related_link['scheme'] . '://' . $sub_domain . '.' . $related_link['host'];
if (!is_null($path)) {
$final_url .= '/' . ltrim($path, '/');
}
return $final_url;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment