Skip to content

FyreURI is a free, open-source URI library for PHP.

License

Notifications You must be signed in to change notification settings

elusivecodes/FyreURI

Repository files navigation

FyreURI

FyreURI is a free, open-source immutable URI library for PHP.

Table Of Contents

Installation

Using Composer

composer require fyre/uri

In PHP:

use Fyre\Http\Uri;

Uri Creation

  • $uriString is a string representing the uri.
$uri = new Uri($uriString);

Alternatively, you can use the fromString method for easier chaining.

$uri = Uri::fromString($uriString);

Methods

Add Query

Add a query parameter.

  • $key is a string representing the query key.
  • $value is the query value.
$newUri = $uri->addQuery($key, $value);

Except Query

Remove query parameters.

  • $keys is an array containing the query parameters to remove.
$newUri = $uri->exceptQuery($keys);

Get Authority

Get the URI authority string.

$authority = $uri->getAuthority();

Get Fragment

Get the URI fragment.

$fragment = $uri->getFragment();

Get Host

Get the URI host.

$host = $uri->getHost();

Get Path

Get the URI path.

$path = $uri->getPath();

Get Port

Get the URI port.

$port = $uri->getPort();

Get Query

Get the URI query array.

$query = $uri->getQuery();

Get Query String

Get the URI query string.

$query = $uri->getQueryString();

Get Scheme

Get the URI scheme.

$scheme = $uri->getScheme();

Get Segment

Get a specified URI segment.

  • $segment is a number indicating the segment index.
$part = $uri->getSegment($segment);

Get Segments

Get the URI segments.

$segments = $uri->getSegments();

Get Total Segments

Get the URI segments count.

$segmentCount = $uri->getTotalSegments();

Get Uri

Get the URI string.

$uriString = $uri->getUri();

Get User Info

Get the user info string.

$userInfo = $uri->getUserInfo();

Only Query

Filter query parameters.

  • $keys is an array containing the query parameters to keep.
$newUri = $uri->onlyQuery($keys);

Set Authority

Set the URI authority string.

  • $authority is a string representing the authority.
$newUri = $uri->setAuthority($authority);

Set Fragment

Set the URI fragment.

  • $fragment is a string representing the fragment.
$newUri = $uri->setFragment($fragment);

Set Host

Set the URI host.

  • $host is a string representing the host.
$newUri = $uri->setHost($host);

Set Path

Set the URI path.

  • $path is a string representing the path.
$newUri = $uri->setPath($path);

Set Port

Get the URI port.

  • $port is a number representing the port.
$newUri = $uri->setPort($port);

Set Query

Get the URI query array.

  • $query is an array containing the query parameters.
$newUri = $uri->setQuery($query);

Set Query String

Get the URI query string.

  • $query is a string representing the query parameters.
$newUri = $uri->setQueryString($query);

Set Scheme

Get the URI scheme.

  • $scheme is a string representing the scheme.
$newUri = $uri->setScheme($scheme);

Set User Info

Get the user info string.

  • $username is a string representing the username.
  • $password is a string representing the password, and will default to "".
$newUri = $uri->setUserInfo($username, $password);

About

FyreURI is a free, open-source URI library for PHP.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages