2017 © Pedro Peláez
 

library url

Helper class to work with url strings.

image

urmaul/url

Helper class to work with url strings.

  • Monday, February 19, 2018
  • by urmaul
  • Repository
  • 1 Watchers
  • 0 Stars
  • 206 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Url

Helper class to work with url strings., (*1)

Build Status, (*2)

Installing

composer require urmaul/url dev-master, (*3)

Creating

use urmaul\url\Url;

$url = new Url('http://urmaul.com/');
// or
$url = Url::from('http://urmaul.com/');

Functions

  • string absolute($baseUrl) - converts url from relative to absolute using base url.
echo Url::from('../html/')->absolute('http://urmaul.com/blog/tags/php/');
// http://urmaul.com/blog/tags/html/

echo Url::from('/blog/')->absolute('http://urmaul.com/blog/tags/php/');
// http://urmaul.com/blog/

echo Url::from('https://github.com/')->absolute('http://urmaul.com/blog/tags/php/');
// https://github.com/
  • string addParam($name, $value) - adds get parameter to url.
echo Url::from('http://urmaul.com/')->addParam('foo', 'bar');
// http://urmaul.com/?foo=bar

echo Url::from('http://urmaul.com/?foo=bar')->addParam('spam', 'ham');
// http://urmaul.com/?foo=bar&spam=ham

echo Url::from('http://urmaul.com/?foo=bar')->addParam('foo', 'spam');
// http://urmaul.com/?foo=spam
  • string addParams($addParams) - adds get parameters to url.
echo Url::from('http://urmaul.com/')->addParams(array('foo' => 'bar'));
// http://urmaul.com/?foo=bar

echo Url::from('http://urmaul.com/?foo=bar')->addParams(array('spam' => 'ham'));
// http://urmaul.com/?foo=bar&spam=ham

echo Url::from('http://urmaul.com/?foo=bar')->addParams(array('foo' => 'spam'));
// http://urmaul.com/?foo=spam
  • string removeParam($name, $value) - removes get parameter from url.
echo Url::from('http://urmaul.com/?foo=bar')->removeParam('foo');
// http://urmaul.com/

echo Url::from('http://urmaul.com/?foo=bar&spam=ham')->removeParam('spam');
// http://urmaul.com/?spam=ham
  • string removeParams($removeParams) - removes get parameters from url.
echo Url::from('http://urmaul.com/?foo=bar')->removeParams(array('foo', 'spam'));
// http://urmaul.com/

echo Url::from('http://urmaul.com/?foo=bar&spam=ham')->removeParams(array('foo', 'spam'));
// http://urmaul.com/

echo Url::from('http://urmaul.com/?foo=bar&foo=spam&ham=spam')->removeParams(array('foo', 'spam'));
// http://urmaul.com/?ham=spam

The Versions

19/02 2018

dev-master

9999999-dev https://github.com/urmaul/url

Helper class to work with url strings.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

url string

19/02 2018

v1.3.1

1.3.1.0 https://github.com/urmaul/url

Helper class to work with url strings.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

url string

16/02 2018

v1.3.0

1.3.0.0 https://github.com/urmaul/url

Helper class to work with url strings.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

url string

25/01 2016

v1.2.1

1.2.1.0 https://github.com/urmaul/url

Helper class to work with url strings.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

url string

16/09 2015

v1.2.0

1.2.0.0 https://github.com/urmaul/url

Helper class to work with url strings.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

url string

25/02 2015

v1.1.0

1.1.0.0 https://github.com/urmaul/url

Helper class to work with url strings.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

url string

04/09 2014

v1.0.1

1.0.1.0 https://github.com/urmaul/url

Helper class to work with url strings.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

url string

06/06 2014

v1.0.0

1.0.0.0 https://github.com/urmaul/url

Helper class to work with url strings.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

url string