Skip to content

yalesov/php-url

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yalesov\Url

Build Status

A collection of url-related functions.

Installation

Composer:

{
  "require": {
    "yalesov/url": "2.*"
  }
}

Usage

Turn a URL, relative or absolute, into an absolute URL:

use Yalesov\Url\Url;
$url = Url::toAbsolute($baseUrl, $relativeUrl);

Filter out . and .. segments from URL's path:

use Yalesov\Url\Url;
$path = Url::removeDotSegments($path);

Split a URL to its components: (reverse of Url::join())

use Yalesov\Url\Url;
$parts = Url::split($url);
// one or more of the following keys may be present:
// $parts['scheme']   = (scheme, such as "http")
// $parts['host']     = (host name, IPv4, or IPv6 address)
// $parts['port']     = (the port number)
// $parts['user']     = (user name)
// $parts['pass']     = (user password)
// $parts['path']     = (path, e.g. a file path for "http")
// $parts['query']    = (the query)
// $parts['fragment'] = (the fragment)

Join together URL components to form a complete URL: (reverse of Url::split())

use Yalesov\Url\Url;
$url = Url::join(array(
  'scheme'   => $scheme,
  'host'     => $host,
  'port'     => $port,
  'user'     => $user,
  'pass'     => $pass,
  'path'     => $path,
  'query'    => $query,
  'fragment' => $fragment,
));

About

A collection of url-related functions.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages