sabre/uri
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Sabre/uri is a potent lightweight library in PHP, designed to provide a plethora of features for working with URIs. It adheres strictly to the guidelines provided by RFC3986. Drawing inspiration from the Node.js URL library, the sabre/uri project evolved to tackle real-world PHP application concerns. The package provides valuable functions to resolve relative URLs, normalize URLs for comparison, parse, and build URLs, and split URLs to retrieve 'dirname' and 'basename'. In terms of versatility, it meets criteria for a wide range of PHP versions, ranging from PHP 5.4.7 to the latest PHP 7.4.
Utilizing sabre/uri in your PHP project is incredibly straightforward. First, you'd need to install it using composer with the command composer require sabre/uri
. Once installed, you can use the functions it provides:
<?php
use Sabre\Uri;
// Resolve relative URLs:
$resolvedURL = Uri\resolve('http://example.org/foo', '../bar'); // returns "http://example.org/bar"
// Normalize URLs:
$normalizedURL = Uri\normalize('HTTP://www.Example.com/'); // returns "http://www.example.com/"
// Parse URLs:
$parsedURL = Uri\parse('http://username:password@example.com:81/path?arg=value#anchor');
// Build URLs:
$builtURL = Uri\build($parsedURL); // returns 'http://username:password@example.com:81/path?arg=value#anchor'
// Split URLs:
$splitURL = Uri\split('http://www.example.com/path/to'); // returns array('http://www.example.com/path/', 'to')
?>
Remember, sabre/uri simplifies handling various URL related tasks, such as resolving relative URIs to absolute URIs, URL normalization, and parsing or building URLs from components.
The official sabre/uri documentation can be found directly on the sabre.io website. For a deep dive into installation processes, usage, examples, and more, visit the sabre/uri documentation. It's a well-maintained resource, perfect for both beginners taking their first steps with the library and experienced developers looking for comprehensive feature descriptions. For unanswered inquiries, you can consider joining the sabre/dav mailing list or opening a ticket on GitHub.