2017 © Pedro Peláez
 

library uri-builder

UriBuilder library simplifies manipulation of Uri value objects compatible with PSR-7

image

k911/uri-builder

UriBuilder library simplifies manipulation of Uri value objects compatible with PSR-7

  • Friday, October 6, 2017
  • by k911
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

UriBuilder

CircleCI, (*1)

Simplifies manipulation of URI value objects compatible with PSR-7. Under the hood, it utilizes League\Uri powerful library., (*2)

Code Climate Test Coverage Issue Count, (*3)

Installation

$ composer require k911/uri-builder

Supported Schemes

Currently supported, tested, URI schemes that UriBuilder can manage and parse from bare URI string or URI components., (*4)

  • http/https
  • ftp/sftp
  • ws/wss
  • file
  • data

Usage

Full public interface is available here., (*5)

Usage example:, (*6)

// Simple URI string
$uri = 'wss://foo.bar:9999';

// Create UriBuilder and its dependencies
// ..you should either use DI container to manage it
// ..or use UriBuilder facade
$parser = new K911\UriBuilder\Adapter\UriParserAdapter();
$factory = new K911\UriBuilder\UriFactory($parser);
$builder = new K911\UriBuilder\UriBuilder($factory);

// Intiliaze UriBuilder with URI string
$builder->from($uri);
// or $builder->fromUri(UriInterface $uri);
// or $builder->fromComponents(array $components);

// UriBuilder is mutable, and allows method chaining
$builder
    // under the hood, it automatically transforms Uri object
    ->setScheme('https')
    // simple setters
    ->setHost('api.foo.bar')
    ->setFragment('foobar')
    // setting DEFAULT port for https scheme
    ->setPort(443)
    // domain-related paths must always start with forward slash '/'
    ->setPath('/v1')
    // query string is generated safely from pairs according to RFC3986
    ->setQuery([
        'api_token' => 'Qwerty! @#$TYu',
    ])
    // set user info (password can be omitted)
    ->setUserInfo('user', 'password');


// Print result
echo (string) $builder->getUri();
// https://user:password@api.foo.bar/v1?api_token=Qwerty%21%20%40%23%24TYu#foobar

The Versions

06/10 2017

dev-master

9999999-dev

UriBuilder library simplifies manipulation of Uri value objects compatible with PSR-7

  Sources   Download

MIT

The Requires

 

The Development Requires

psr-7 http uri builder

06/10 2017

dev-develop

dev-develop

UriBuilder library simplifies manipulation of Uri value objects compatible with PSR-7

  Sources   Download

MIT

The Requires

 

The Development Requires

psr-7 http uri builder

06/10 2017

v0.9.0

0.9.0.0

UriBuilder library simplifies manipulation of Uri value objects compatible with PSR-7

  Sources   Download

MIT

The Requires

 

The Development Requires

psr-7 http uri builder