The League of Extraordinary Packages

Our Packages:

Presented by The League of Extraordinary Packages

Getting Started

The API

The Components

Url is end of life. We strongly encourage you to use League\Uri instead.

Installation

System Requirements

Composer

URL is available on Packagist and can be installed using Composer:

composer require league/url

This will edit (or create) your composer.json file and automatically choose the most recent version, for example: ~3.0

Most modern frameworks will include Composer out of the box, but ensure the following file is included:

<?php

// Include the Composer autoloader
require 'vendor/autoload.php';

Going Solo

You can also use URL without using Composer by registing an autoloader function:

<?php

spl_autoload_register(function ($class) {
    $prefix = 'League\\Url\\';
    $base_dir = __DIR__ . '/src/';
    $len = strlen($prefix);
    if (strncmp($prefix, $class, $len) !== 0) {
        // no, move to the next registered autoloader
        return;
    }
    $relative_class = substr($class, $len);
    $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
    if (file_exists($file)) {
        require $file;
    }
});

Or, use any other PSR-4 compatible autoloader.