romeoz / rock-url
A simple PHP library to parse and builder URLs
Installs: 1 419
Dependents: 4
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.4.0
- romeoz/rock-request: 0.14.*
Requires (Dev)
- phpunit/phpunit: ^4.7.0
Suggests
- romeoz/rock-csrf: required for generating CSRF-token (security)
README
Installation
From the Command Line:
composer require romeoz/rock-url
In your composer.json:
{ "require": { "romeoz/rock-url": "*" } }
Quick Start
use rock\url\Url; // example URL: http://site.com/foo/?page=1 // returns relative URL (new Url)->getRelative(); // output: /foo/?page=1 // modify URL Url::set('https://site.com/?page=2#name')->removeFragment()->getRelative(); //output: /?page=2 Url::set('https://site.com/?page=2#name')->removeQueryParams(['page'])->getAbsolute(); //output: https://site.com/#name
###Short method modify()
Url::modify(['https://site.com/', 'foo' => 'test', '#' => 'name']); //output: /?foo=test#name Url::modify(['https://site.com/?foo=test#name', '!foo', '!#', '@scheme' => Url::ABS]); //output: https://site.com/ // modify current url Url::modify([foo' => 'test]); //output: /?foo=test
Requirements
- PHP 5.4+
- For generating CSRF-token (security) required Rock CSRF:
composer require romeoz/rock-csrf
All unbolded dependencies is optional
License
Rock URL library is open-sourced software licensed under the MIT license.