transprime-research/php-url is a Laravel package for urls in php made easy.
It currently has 2 GitHub stars and 21 downloads on Packagist (latest version 1.0.2).
Install it with composer require transprime-research/php-url.
Discover more Laravel packages by transprime-research
or browse all Laravel packages to compare alternatives.
Last updated
This works this way
Do it Like a PRO :ok:
composer require transprime-research/php-urlUse it like this...
$url = new Url(
fullDomain: 'http://localhost:8080',
path: '/api/hello',
query: ['name' => 'John', 'public' => 'yes'],
);
// Or
$url = Url::make(
scheme: 'http://',
domain: 'localhost',
port: '8080',
path: '/api/hello',
query: ['name' => 'John', 'public' => 'yes'],
);
(string) $url; // http://localhost:8080/api/hello?name=John&public=yes
$url->toString(); // http://localhost:8080/api/hello?name=John&public=yes
$url = Url::make()
->setScheme('http://')
->setDomain('localhost')
->setPort('8080')
->setPath('/api/hello')
->addToQuery('name', 'John')
->addToQuery('public', 'yes');
(string) $url; // http://localhost:8080/api/hello?name=John&public=yes
Api implementation to be decided
See other packages in this series here:
MIT (See LICENCE file)