A collection of url-related functions.

v2.0.4 2016-07-06 12:21 UTC

This package is not auto-updated.

Last update: 2024-12-21 14:17:21 UTC


README

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,
));