Download the PHP package ozh/http_build_url without Composer
On this page you can find all versions of the php package ozh/http_build_url. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package http_build_url
http_build_url() for PHP
An implementation of http_build_url(),
the URL builder from the pecl_http extension, for environments where that
extension isn't installed.
About this fork
The original package, jakeasmith/http_build_url,
was abandoned in favor of the URI API built into PHP 8.5. That's good advice for new
code, but plenty of existing projects still call http_build_url() and just need
it to keep working on modern PHP. So this fork picks up maintenance:
- published on Packagist as
ozh/http_build_url - PHP 8.1+ only, typed signature
- same behavior and same function name as the original, so switching is a one-line change in
composer.json
If you are starting fresh on PHP 8.5+, use Uri\Rfc3986\Uri
instead; see Modern alternative below.
Install
Usage
$url and $parts are each either a URL string or an associative array in the
shape parse_url() returns. The parts of $parts are merged into $url
according to $flags. If $new_url is passed, it is filled with the parts of
the resulting URL, as parse_url() would return them.
Flags
| Constant | Effect |
|---|---|
HTTP_URL_REPLACE |
Replace every part given in $parts (default) |
HTTP_URL_JOIN_PATH |
Join the path of $parts onto the path of $url |
HTTP_URL_JOIN_QUERY |
Merge the query strings of $url and $parts |
HTTP_URL_STRIP_USER |
Strip the user |
HTTP_URL_STRIP_PASS |
Strip the password |
HTTP_URL_STRIP_AUTH |
Strip user and password |
HTTP_URL_STRIP_PORT |
Strip the port |
HTTP_URL_STRIP_PATH |
Strip the path |
HTTP_URL_STRIP_QUERY |
Strip the query string |
HTTP_URL_STRIP_FRAGMENT |
Strip the fragment |
HTTP_URL_STRIP_ALL |
Strip everything but scheme and host |
Scheme and host given in $parts are always applied, regardless of flags. The
constants are defined only if they don't already exist, and use the same values
as pecl_http.
Modern alternative
On PHP 8.5+, the built-in URI API covers most of the same ground:
Tests
License
MIT, as the original. See LICENSE.