<p>Is there a widely accepted class for dealing with URLs in PHP?</p>

<p>Things like: getting/changing parts of an existing URL (e.g. path, scheme, etc), resolving relative paths from a base URL.  Kind of like a two-way <a href="http://php.net/parse_url" rel="nofollow noreferrer">parse_url()</a>, encapsulated with a bunch of handy functions.</p>

<p>Does something like this exist?</p>

This
URL.php class
may be a good start (not sure it is 'widely' accepted though).
URL class intended for http and https schemes
This class allows you store absolute or relative URLs and access it's various parts (scheme, host, port, part, query, fragment).
It will also accept and attempt to resolve a relative URL against an absolute URL already stored.
Note: this URL class is based on the HTTP scheme.
Example:
```
```
$url =& new URL('http://www.domain.com/path/file.php?query=blah');
echo $url->get_scheme(),"\n";    // http
echo $url->get_host(),"\n";      // www.domain.com
echo $url->get_path(),"\n";      // /path/file.php
echo $url->get_query(),"\n";     // query=blah
// Setting a relative URL against our existing URL
$url->set_relative('../great.php');
echo $url->as_string(); // http://www.domain.com/great.php
```
```