Download the PHP package kuria/url without Composer

On this page you can find all versions of the php package kuria/url. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package url

Url ###

Parsing, modifying and building URLs.

:depth: 3

Features

Requirements

Usage

Creating a new URL

Create a new instance of Url and use constructor arguments or setters to define the components:

$url = new Url();

$url->setScheme('http'); $url->setHost('example.com'); $url->setPath('/test'); // many more setters are available..

echo $url;

Output:

http://example.com/test

Parsing an URL

$url = Url::parse('http://example.com:8080/test?foo=bar&lorem=ipsum#fragment');

Getting URL components

// checking whether a certain component is defined var_dump( $url->hasScheme(), $url->hasHost(), $url->hasPort(), $url->hasPath(), $url->hasQuery(), $url->hasFragment() );

Output:

string(4) "http"
string(11) "example.com"
string(16) "example.com:8080"
int(8080)
string(5) "/test"
array(2) {
  ["foo"]=>
  string(3) "bar"
  ["lorem"]=>
  string(5) "ipsum"
}
string(8) "fragment"
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)

Getting query parameters

$url = Url::parse('/test?foo=bar&lorem%5B0%5D=ipsum&lorem%5B1%5D=dolor');

var_dump( $url->has('foo'), $url->has('nonexistent'), $url->get('foo'), $url->get('lorem'), $url->get('nonexistent') );

Output:

bool(true)
bool(false)
string(3) "bar"
array(2) {
  [0]=>
  string(5) "ipsum"
  [1]=>
  string(5) "dolor"
}
NULL

Manipulating query parameters

Setting a single parameter

Removing a single parameter

Setting multiple parameters

Replacing all parameters

Removing all parameters

Building URLs

Using build() or __toString()

These methods will return an absolute or relative URL.

Output:

string(5) "/test"
string(23) "http://example.com/test"

Specifying a preferred format

By default, build() and __toString() return an absolute URL if the host is specified.

This behavior can be changed by passing the $preferredFormat parameter to the constructor, Url::parse() or the setPreferredFormat() method.

Output:

http://example.com/foo
/foo

Using buildAbsolute()

This method will always return an absolute URL.

If the host is not defined, Kuria\Url\Exception\IncompleteUrlException will be thrown.

$url = new Url();

$url->setScheme('http'); $url->setHost('example.com'); $url->setPath('/test');

var_dump($url->buildAbsolute());

Output:

string(23) "http://example.com/test"

Using buildRelative()

This method will always return a relative URL regardless of whether the host is defined or not.

$url = new Url();

$url->setScheme('http'); $url->setHost('example.com'); $url->setPath('/test');

var_dump($url->buildRelative());

Output:

string(5) "/test"

All versions of url with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kuria/url contains the following files

Loading the files please wait ....