https://github.com/elusivecodes/fyreuri
FyreURI is a free, open-source URI library for PHP.
https://github.com/elusivecodes/fyreuri
php uri
Last synced: 6 months ago
JSON representation
FyreURI is a free, open-source URI library for PHP.
- Host: GitHub
- URL: https://github.com/elusivecodes/fyreuri
- Owner: elusivecodes
- License: mit
- Created: 2021-12-01T10:27:44.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-06-29T02:00:24.000Z (11 months ago)
- Last Synced: 2024-09-01T04:10:02.805Z (9 months ago)
- Topics: php, uri
- Language: PHP
- Homepage:
- Size: 75.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FyreURI
**FyreURI** is a free, open-source immutable URI library for *PHP*.
## Table Of Contents
- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Methods](#methods)## Installation
**Using Composer**
```
composer require fyre/uri
```In PHP:
```php
use Fyre\Http\Uri;
```## Basic Usage
- `$uriString` is a string representing the uri.
```php
$uri = new Uri($uriString);
```Alternatively, you can use the `fromString` method for easier chaining.
```php
$uri = Uri::fromString($uriString);
```## Methods
**Add Query**
Add a query parameter.
- `$key` is a string representing the query key.
- `$value` is the query value.```php
$newUri = $uri->addQuery($key, $value);
```**Except Query**
Remove query parameters.
- `$keys` is an array containing the query parameters to remove.
```php
$newUri = $uri->exceptQuery($keys);
```**Get Authority**
Get the URI authority string.
```php
$authority = $uri->getAuthority();
```**Get Fragment**
Get the URI fragment.
```php
$fragment = $uri->getFragment();
```**Get Host**
Get the URI host.
```php
$host = $uri->getHost();
```**Get Path**
Get the URI path.
```php
$path = $uri->getPath();
```**Get Port**
Get the URI port.
```php
$port = $uri->getPort();
```**Get Query**
Get the URI query array.
```php
$query = $uri->getQuery();
```**Get Query String**
Get the URI query string.
```php
$query = $uri->getQueryString();
```**Get Scheme**
Get the URI scheme.
```php
$scheme = $uri->getScheme();
```**Get Segment**
Get a specified URI segment.
- `$segment` is a number indicating the segment index.
```php
$part = $uri->getSegment($segment);
```**Get Segments**
Get the URI segments.
```php
$segments = $uri->getSegments();
```**Get Total Segments**
Get the URI segments count.
```php
$segmentCount = $uri->getTotalSegments();
```**Get Uri**
Get the URI string.
```php
$uriString = $uri->getUri();
```**Get User Info**
Get the user info string.
```php
$userInfo = $uri->getUserInfo();
```**Only Query**
Filter query parameters.
- `$keys` is an array containing the query parameters to keep.
```php
$newUri = $uri->onlyQuery($keys);
```**Set Authority**
Set the URI authority string.
- `$authority` is a string representing the authority.
```php
$newUri = $uri->setAuthority($authority);
```**Set Fragment**
Set the URI fragment.
- `$fragment` is a string representing the fragment.
```php
$newUri = $uri->setFragment($fragment);
```**Set Host**
Set the URI host.
- `$host` is a string representing the host.
```php
$newUri = $uri->setHost($host);
```**Set Path**
Set the URI path.
- `$path` is a string representing the path.
```php
$newUri = $uri->setPath($path);
```**Set Port**
Get the URI port.
- `$port` is a number representing the port.
```php
$newUri = $uri->setPort($port);
```**Set Query**
Get the URI query array.
- `$query` is an array containing the query parameters.
```php
$newUri = $uri->setQuery($query);
```**Set Query String**
Get the URI query string.
- `$query` is a string representing the query parameters.
```php
$newUri = $uri->setQueryString($query);
```**Set Scheme**
Get the URI scheme.
- `$scheme` is a string representing the scheme.
```php
$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 *""*.```php
$newUri = $uri->setUserInfo($username, $password);
```