2017 © Pedro Peláez
 

library purl

A PHP port of the furl library by gruns

image

mrferos/purl

A PHP port of the furl library by gruns

  • Monday, November 4, 2013
  • by mrferos
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

purl

A shameless port of the furl python library to PHP to make URL manipulation easy.

The Query

Manipulating the url query is easy:, (*1)

$url = \Purl\Purl::fromString('http://www.google.com/?one=1&two=2');
unset($url['one']);
$url['three'] = 'foo';
echo $url->toString();
// http://www.google.com/?two=2&three=foo
````

Alternatively you can do the same like so:
```php
$url = \Purl\Purl::fromString('http://www.google.com/?one=1&two=2');
$url->getQuery()->add('three','foo')
                ->remove('one');
echo $url;
// http://www.google.com/?two=2&three=foo

Still one more way since the query has easy accessor methods in the Purl object:, (*2)

$url = \Purl\Purl::fromString('http://www.google.com/?one=1&two=2');
$url->add('three', 'foo')
    ->remove('one');
echo $url;
// http://www.google.com/?two=2&three=foo

The Path

You can add or remove from the path like so:, (*3)

$url = \Purl\Purl::fromString('http://www.google.com/path/?foo=2');
$url->getPath()->add('second-part');
// 'http://www.google.com/path/second-part/?foo=2'
$url->getPath()->remove('path');
// http://www.google.com/second-part/?foo=2

The Fragment

Fragments can be edited like so:, (*4)

$url = \Purl\Purl::fromString('http://www.google.com/path/?foo=2#fragment/foo?arg=one');
$url->getFragment()->getQuery()->remove('arg');
// http://www.google.com/path/?foo=2#fragment/foo
$url->getFragment()->getPath()->remove('foo');
// http://www.google.com/path/?foo=2#fragment

Bitdeli Badge, (*5)

The Versions

04/11 2013

dev-master

9999999-dev

A PHP port of the furl library by gruns

  Sources   Download

The Requires

  • php >=5.3.0

 

by Andres Galindo