gfg/dto-url

This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (1.0.1) of this package.

Library to handle and wrap URL informations

Maintainers

Details

github.com/GFG/dto-url

Source

Issues

Installs: 8 970

Dependents: 2

Suggesters: 0

Security: 0

Stars: 1

Watchers: 6

Forks: 0

Open Issues: 0

pkg:composer/gfg/dto-url

1.0.1 2016-03-28 20:36 UTC

This package is not auto-updated.

Last update: 2019-02-20 19:24:13 UTC


README

Scrutinizer Code Quality Code Coverage Build Status Latest Stable Version Total Downloads License Forks Stars

INTRODUCTION

Tiny library for encapsulating an URL.

EXAMPLES OF USE

<?php

use GFG\DTOUrl\Url;

$urlParts = [
    'scheme'   => 'http',
    'host'     => 'externalshop.com',
    'port'     => 80,
    'user'     => 'username',
    'pass'     => 'password',
    'path'     => ['api', 'version', 'action'],
    'query'    => ['query' => 'string'],
    'fragment' => 'first'
];
$url = new Url($urlParts);

// http://username:password@externalshop.com:80/api/version/action?query=string#first
echo $url->getFullUrl();
<?php

use GFG\DTOUrl\Url;

$urlParts = [
    'scheme'   => 'https',
    'host'     => 'www.externalshop.com',
    'path'     => ['test']
];
$url = new Url($urlParts);

// https://www.externalshop.com/test
echo $url->getFullUrl();
<?php

use GFG\DTOUrl\Url;

$urlParts = [
    'path' => [
        'api', 
        'version' => 'version',
        'partnerCode' => 'partner-code',
        'product'
    ]
];
$url = new Url($urlParts);

$replace = [
    'version'     => 2,
    'partnerCode' => 'kanui'
];
$url->replacePath($replace);

// api/2/kanui/product
echo $url->getFullUrl();
<?php

use GFG\DTOUrl\Url;

$urlParts = [
    'scheme'   => 'http',
    'host'     => 'externalshop.com',
    'port'     => 80,
    'user'     => 'username',
    'pass'     => 'password',
    'path'     => ['api', 'version', 'action'],
    'query'    => ['query' => 'string'],
    'fragment' => 'first'
];
$url = new Url($urlParts);

$paths = [
    'version' => 'version',
    'create',
    'product'
];
$replace = ['version' => '2.0'];
$url->setPath($paths)->replacePath($replace);

// http://username:password@externalshop.com:80/2.0/create/product?query=string#first
echo $this->url->getFullUrl();
<?php

use GFG\DTOUrl\Url;

$urlParts = [
    'scheme'   => 'http',
    'host'     => 'externalshop.com',
    'port'     => 80,
    'user'     => 'username',
    'pass'     => 'password',
    'path'     => ['api', 'version', 'action'],
    'query'    => ['query' => 'string'],
    'fragment' => 'first'
];
$url = new Url($urlParts);

$query = ['name' => 'name'];
$replace = ['name' => 'fullname'];
$url->setQuery($query)->replaceQuery($replace);

// http://username:password@externalshop.com:80/api/version/action?name=fullname#first
echo $url->getFullUrl();