dubovlab/url-parser-formatter

There is no license information available for the latest version (dev-master) of this package.

URL parsing and formatting library for PHP ^7.2

Installs: 12

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 0

Forks: 0

Open Issues: 1

pkg:composer/dubovlab/url-parser-formatter

dev-master 2019-12-01 09:49 UTC

This package is not auto-updated.

Last update: 2025-12-22 16:26:42 UTC


README

URL parsing and formatting library

Usage

composer require dubovlab/url-parser-formatter

Core functions

<?php

require_once __DIR__ . '/vendor/autoload.php';

$str = 'https://user:pass@host:55555/root/dir/file.ext?query_key=query_value&query_key2=query_value2#fragment_key=fragment_value&fragment_key2=fragment_value2';

$components = \url\parse($str);

echo $components['scheme'] . '://' . $components['host'] . ':' . $components['port'] . PHP_EOL;

echo \url\format($components) . PHP_EOL; 

Url class

<?php 

require_once __DIR__ . '/vendor/autoload.php';

$str = '/root/dir/file.ext?query_key=query_value&query_key2=query_value2#fragment_key=fragment_value&fragment_key2=fragment_value2';
$base_url = 'https://user:pass@host:55555';

$url = \url\Url::parse($str, $base_url);

echo $url->scheme . '://' . $url->host . ':' . $url->port . PHP_EOL;

echo $url->format(null, ['scheme', 'host', 'port']) . PHP_EOL;

echo $url->query('query_key2') . PHP_EOL;

echo $url->fragment('fragment_key') . PHP_EOL;

echo $url . PHP_EOL;

Todo list:

  • function reference
  • normalize_path()