The League of Extraordinary Packages

Our Packages:

Presented by The League of Extraordinary Packages

Getting Started


The Components

Url is end of life. We strongly encourage you to use League\Uri instead.

The Host class

This class is a segment values component class and manage the URL host component. It implementings the League\Url\Components\HostInterface too.

The interface provides methods to deal with IDN.


added in version 3.1

This method is an alias of __toString() and return the hostname internationalized name


added in version 3.1

Returns the Punycode encoded hostname;


use League\Url\Components\Host;

$host = new Host;
$host->set('스타벅스코리아.com'); //you set the IDN
//will display
// array(
//    0 => '스타벅스코리아',
//    1 => 'com'
// )
echo $host->toAscii(); // output ''
echo $host->toUnicode();  // output '스타벅스코리아.com'

$host->set('xn--mgbh0fb.xn--kgbechtv'); //you set a ascii hostname
echo $host;  // output 'مثال.إختبار'  //the object output the IDN version