@@ -123,6 +123,7 @@ to apply the following changes to the submitted URI.
123123<div >
124124<h4 >Query modifiers</h4 >
125125<ul >
126+ <li ><a href =" #modifierwithquery " >withQuery</a ></li >
126127 <li ><a href =" #modifierencodequery " >encodeQuery</a ></li >
127128 <li ><a href =" #modifiersortquery " >sortQuery</a ></li >
128129 <li ><a href =" #modifiermergequery " >mergeQuery</a ></li >
@@ -137,19 +138,9 @@ to apply the following changes to the submitted URI.
137138</ul >
138139</div >
139140<div >
140- <h4 >Fragment modifiers <span class =" text-red-800 text-sm " >since <code class =" text-sm " >7.6.0</code ></span ></h4 >
141- <ul >
142- <li ><a href =" #modifierappendfragmentdirectives " >appendFragmentDirectives</a ></li >
143- <li ><a href =" #modifierprependfragmentdirectives " >prependFragmentDirectives</a ></li >
144- <li ><a href =" #modifierremovefragmentdirectives " >removeFragmentDirectives</a ></li >
145- <li ><a href =" #modifierreplacefragmentdirective " >replaceFragmentDirective</a ></li >
146- <li ><a href =" #modifierfilterfragmentdirectives " >filterFragmentDirectives</a ></li >
147- <li ><a href =" #modifierslicefragmentdirectives " >sliceFragmentDirectives</a ></li >
148- </ul >
149- </div >
150- <div >
151141<h4 >Host modifiers</h4 >
152142<ul >
143+ <li ><a href =" #modifierwithhost " >withHost</a ></li >
153144 <li ><a href =" #modifiernormalizehost " >normalizeHost</a ></li >
154145 <li ><a href =" #modifierhosttoascii " >hostToAscii</a ></li >
155146 <li ><a href =" #modifierhosttounicode " >hostToUnicode</a ></li >
@@ -171,6 +162,7 @@ to apply the following changes to the submitted URI.
171162<div >
172163<h4 >Path modifiers</h4 >
173164<ul >
165+ <li ><a href =" #modifierwithpath " >withPath</a ></li >
174166 <li ><a href =" #modifierremovedotsegments " >removeDotSegments</a ></li >
175167 <li ><a href =" #modifierremoveemptysegments " >removeEmptySegments</a ></li >
176168 <li ><a href =" #modifierremovetrailingslash " >removeTrailingSlash</a ></li >
@@ -192,16 +184,54 @@ to apply the following changes to the submitted URI.
192184 <li ><a href =" #modifierdatapathtoascii " >dataPathToAscii</a ></li >
193185</ul >
194186</div >
187+ <div >
188+ <h4 >Fragment modifiers <span class =" text-red-800 text-sm " >since <code class =" text-sm " >7.6.0</code ></span ></h4 >
189+ <ul >
190+ <li ><a href =" #modifierwithfragment " >withFragment</a ></li >
191+ <li ><a href =" #modifierappendfragmentdirectives " >appendFragmentDirectives</a ></li >
192+ <li ><a href =" #modifierprependfragmentdirectives " >prependFragmentDirectives</a ></li >
193+ <li ><a href =" #modifierremovefragmentdirectives " >removeFragmentDirectives</a ></li >
194+ <li ><a href =" #modifierreplacefragmentdirective " >replaceFragmentDirective</a ></li >
195+ <li ><a href =" #modifierfilterfragmentdirectives " >filterFragmentDirectives</a ></li >
196+ <li ><a href =" #modifierslicefragmentdirectives " >sliceFragmentDirectives</a ></li >
197+ </ul >
198+ </div >
199+ <div >
200+ <h4 >Component modifiers <span class =" text-red-800 text-sm " >since <code class =" text-sm " >7.6.0</code ></span ></h4 >
201+ <ul >
202+ <li><a href="#modifierwithscheme">withScheme</a></li>
203+ <li><a href="#modifierwithuserinfo">withUserInfo</a></li>
204+ <li><a href="#modifierwithport">withPort</a></li>
205+ <li><a href="#modifierresovlve">URI resolve</a></li>
206+ </ul >
207+ </div >
195208</div >
196209
197- ## Query modifiers
198210
199- The following modifiers update and normalize the URI query component.
211+ ## Query Modifiers
212+
213+ Following modifiers update and normalize the URI query component.
200214
201215<p class =" message-notice " >Because each modification is done after parsing and building, the
202216resulting query string may update the component character encoding. These changes are expected because of
203217the rules governing parsing and building query string.</p >
204218
219+ ### Modifier::withQuery
220+
221+ <p class =" message-notice " >since version <code >7.6.0</code ></p >
222+
223+ Change the full query component.
224+
225+ ~~~ php
226+ use League\Uri\Modifier;
227+
228+ echo Modifier::from("https://example.com/?kingkong=toto&foo=bar%20baz&kingkong=ape")
229+ ->withQuery('foo=bar')
230+ ->uri()
231+ ->getQuery();
232+ //display "foo=bar"
233+ ~~~
234+
205235### Modifier::encodeQuery
206236
207237<p class =" message-notice " >since version <code >7.1.0</code ></p >
@@ -384,7 +414,23 @@ echo $newUri->uri()->getQuery(); //display "kingkong=toto&fo.o=champion&fo_o=bar
384414
385415## Host modifiers
386416
387- The following modifiers update and normalize the URI host component according to RFC3986 or RFC3987.
417+ The following methods update and normalize the URI host component according to the underlying URI object.
418+
419+ ### Modifier::withHost
420+
421+ <p class =" message-notice " >since version <code >7.6.0</code ></p >
422+
423+ Change the full query component.
424+
425+ ~~~ php
426+ use League\Uri\Modifier;
427+
428+ echo Modifier::from("https://example.com/?kingkong=toto&foo=bar%20baz&kingkong=ape")
429+ ->withHost('hello.be')
430+ ->uri()
431+ ->getHost();
432+ //display "hello.be"
433+ ~~~
388434
389435### Modifier::hostToAscii
390436
@@ -664,6 +710,22 @@ echo Modifier::from($uri)->sliceLabels(1, 1)->toString();
664710the resulting path may update the component character encoding. These changes are
665711expected because of the rules governing parsing and building path string.</p >
666712
713+ ### Modifier::withPath
714+
715+ <p class =" message-notice " >since version <code >7.6.0</code ></p >
716+
717+ Change the full path component.
718+
719+ ~~~ php
720+ use League\Uri\Modifier;
721+
722+ echo Modifier::from("https://example.com/?kingkong=toto&foo=bar%20baz&kingkong=ape")
723+ ->withPath('/path/to')
724+ ->uri()
725+ ->getPath();
726+ //display "/path/to"
727+ ~~~
728+
667729### Modifier::removeDotSegments
668730
669731Removes dot segments according to RFC3986:
@@ -906,6 +968,22 @@ echo Modifier::from($uri)
906968
907969## Fragment Modifiers
908970
971+ ### Modifier::withFragment
972+
973+ <p class =" message-notice " >since version <code >7.6.0</code ></p >
974+
975+ Change the full fragment component.
976+
977+ ~~~ php
978+ use League\Uri\Modifier;
979+
980+ echo Modifier::from("https://example.com/?kingkong=toto&foo=bar%20baz&kingkong=ape")
981+ ->withFragment('/path/to')
982+ ->uri()
983+ ->getFragment();
984+ //display "/path/to"
985+ ~~~
986+
909987### Modifier::appendFragmentDirectives
910988
911989<p class =" message-notice " >available since version <code >7.6.0</code ></p >
@@ -1008,15 +1086,22 @@ echo Modifier::from($uri)
10081086// display ":~:text=foo,bar&text=yes"
10091087~~~
10101088
1011- ### General modification
1089+ ## General modifications
10121090
10131091<p class =" message-notice " >available since version <code >7.6.0</code ></p >
10141092
1015- To ease modifying URI since version 7.6.0 you can directly access the modifier methods from the underlying
1016- URI object.
1093+ To ease modifying URI since version ` 7.6.0 ` you can directly access:
1094+
1095+ - the modifier methods from the underlying URI object or
1096+ - resolve an URI base on the underlying URI object rules or
1097+ - normalize an URI base on the underlying URI object rules.
1098+
1099+ The difference being that the ` Modifier ` class will perform the correct conversion
1100+ to handle the differences between URI object signature.
10171101
10181102``` php
10191103use League\Uri\Modifier;
1104+ use Uri\WhatWg\Url;
10201105
10211106$foo = '';
10221107echo Modifier::from('http://bébé.be')
@@ -1032,4 +1117,11 @@ echo Modifier::from('http://bébé.be')
10321117 ->withFragment('chapter1')
10331118 ->toDisplayString();
10341119// returns 'http://shop.bébé.be./toto?fname=john&lname=Doe&foo=toto&foo=tata#chapter1';
1120+
1121+ echo Modifier::from(new Url('http://bébé.be/../do/it'))
1122+ ->appendSegment('toto')
1123+ ->resolve('./foo/../bar')
1124+ ->uri()
1125+ ->toAsciiString(), PHP_EOL;
1126+ // returns http://xn--bb-bjab.be/do/it/bar
10351127```
0 commit comments