@@ -65,7 +65,8 @@ require_once '../vendor/autoload.php';
65
65
66
66
$pslManager = new Pdp\PublicSuffixListManager();
67
67
$parser = new Pdp\Parser($pslManager->getList());
68
- $url = $parser->parseUrl('http://user:
[email protected] :8080/path/to/page.html?query=string#fragment');
68
+ $host = 'http://user:
[email protected] :8080/path/to/page.html?query=string#fragment';
69
+ $url = $parser->parseUrl($host);
69
70
var_dump($url);
70
71
```
71
72
@@ -99,13 +100,90 @@ class Pdp\Uri\Url#6 (8) {
99
100
}
100
101
```
101
102
103
+ ### IDNA Support
104
+
105
+ #### Unicode
106
+
107
+ [ IDN (Internationalized Domain Name)] ( http://en.wikipedia.org/wiki/Internationalized_domain_name )
108
+ support was added in 1.4.0. Setting ` $host = 'Яндекс.РФ'; ` (Russian-Cyrillic)
109
+ in the previous example would return:
110
+
111
+ ```
112
+ class Pdp\Uri\Url#6 (8) {
113
+ private $scheme =>
114
+ string(4) "http"
115
+ private $host =>
116
+ class Pdp\Uri\Url\Host#5 (4) {
117
+ private $subdomain =>
118
+ NULL
119
+ private $registerableDomain =>
120
+ string(17) "яндекс.рф"
121
+ private $publicSuffix =>
122
+ string(4) "рф"
123
+ private $host =>
124
+ string(17) "яндекс.рф"
125
+ }
126
+ private $port =>
127
+ NULL
128
+ private $user =>
129
+ NULL
130
+ private $pass =>
131
+ NULL
132
+ private $path =>
133
+ NULL
134
+ private $query =>
135
+ NULL
136
+ private $fragment =>
137
+ NULL
138
+ }
139
+ ```
140
+
141
+ #### ASCII (Punycode)
142
+
143
+ If you choose to provide the ASCII equivalent of the unicode domain name
144
+ (` $host = 'http://xn--d1acpjx3f.xn--p1ai'; ` in the case of the above example),
145
+ the ASCII equivalent will be returned by the parser:
146
+
147
+ ```
148
+ class Pdp\Uri\Url#6 (8) {
149
+ private $scheme =>
150
+ string(4) "http"
151
+ private $host =>
152
+ class Pdp\Uri\Url\Host#5 (4) {
153
+ private $subdomain =>
154
+ NULL
155
+ private $registerableDomain =>
156
+ string(22) "xn--d1acpjx3f.xn--p1ai"
157
+ private $publicSuffix =>
158
+ string(8) "xn--p1ai"
159
+ private $host =>
160
+ string(22) "xn--d1acpjx3f.xn--p1ai"
161
+ }
162
+ private $port =>
163
+ NULL
164
+ private $user =>
165
+ NULL
166
+ private $pass =>
167
+ NULL
168
+ private $path =>
169
+ NULL
170
+ private $query =>
171
+ NULL
172
+ private $fragment =>
173
+ NULL
174
+ }
175
+ ```
176
+
177
+ ### Convenience Methods
178
+
102
179
A magic __ get() method is provided to access the above object properties. Obtaining the
103
180
public suffix for a parsed domain is as simple as:
104
181
105
182
``` php
106
183
<?php
107
184
108
- $url = $parser->parseUrl('waxaudio.com.au');
185
+ $host = 'waxaudio.com.au';
186
+ $url = $parser->parseUrl($host);
109
187
$publicSuffix = $url->host->publicSuffix;
110
188
111
189
// $publicSuffix = 'com.au'
0 commit comments