PHPackages                             shineforge/compass - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. shineforge/compass

ActiveLibrary[HTTP &amp; Networking](/categories/http)

shineforge/compass
==================

A modern, robust, and PSR-7 compatible URL manipulation library for PHP.

1.0.0(10mo ago)00MITPHPPHP &gt;=8.1CI passing

Since Jul 21Pushed 10mo agoCompare

[ Source](https://github.com/shineforge/compass)[ Packagist](https://packagist.org/packages/shineforge/compass)[ RSS](/packages/shineforge-compass/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (4)Used By (0)

shineforge/compass
==================

[](#shineforgecompass)

[![License](https://camo.githubusercontent.com/0bcdda68d7c4ff1b1dae975bed8cb375d6a35c2eac1bd074956f325335f4fdc5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7368696e65666f7267652f636f6d70617373)](https://github.com/shineforge/compass/blob/main/LICENSE)[![Latest Version](https://camo.githubusercontent.com/a4aa27d11f3bbb6f78554aea93eba4b36287775012dd8fb135d2bf340a9cf5a1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7368696e65666f7267652f636f6d706173733f6c6162656c3d6c6174657374)](https://packagist.org/packages/shineforge/compass/)[![PHP Version](https://camo.githubusercontent.com/8d3fc6b8f22ed848265069310d0bb30a2c698c35953afb2511d5272400f62846/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f7368696e65666f7267652f636f6d706173732f7068703f6c6162656c3d706870)](https://www.php.net/releases/index.php)[![Main Status](https://camo.githubusercontent.com/1f0ee2404a0094a6a1fd403630280d366a780413f5ea9b406ed1ec5d5932ba35/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7368696e65666f7267652f636f6d706173732f7665726966792e796d6c3f6272616e63683d6d61696e266c6162656c3d6d61696e)](https://github.com/shineforge/compass/actions/workflows/verify.yml?query=branch%3Amain)[![Release Status](https://camo.githubusercontent.com/3ba517efd45167b4fa9b68f0537a96357b31a80fcdba9785de719fab5e0b9225/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7368696e65666f7267652f636f6d706173732f7665726966792e796d6c3f6272616e63683d72656c65617365266c6162656c3d72656c65617365)](https://github.com/shineforge/compass/actions/workflows/verify.yml?query=branch%3Arelease)[![Develop Status](https://camo.githubusercontent.com/f673b4b0ebf6b1e6915aa6f06482d6bee7c542e29a9195d52a2c0c40496e6fd6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7368696e65666f7267652f636f6d706173732f7665726966792e796d6c3f6272616e63683d646576656c6f70266c6162656c3d646576656c6f70)](https://github.com/shineforge/compass/actions/workflows/verify.yml?query=branch%3Adevelop)

Description
-----------

[](#description)

Compass provides a powerful `URL` class that simplifies parsing, building, and manipulating URLs in your PHP applications. It offers an intuitive, immutable API for handling all parts of a URL, from the scheme to the fragment.

Key features include:

- **PSR-7 `UriInterface` Compatibility**: Use it as a drop-in replacement wherever a PSR-7 URI is needed.
- **Immutable API**: All modification methods (`with...`) return a new instance, ensuring predictable and safe state management.
- **Advanced Path Resolution**: Easily convert between absolute and relative URLs, and canonicalize paths (resolving `.` and `..` segments).
- **Robust Parsing**: Handles complex URLs gracefully.

Installation
------------

[](#installation)

Install the library using Composer:

```
composer require shineforge/compass
```

Usage
-----

[](#usage)

### Creating a URL

[](#creating-a-url)

You can create a `URL` instance from a string.

```
