{"id":3073,"date":"2025-11-18T14:29:22","date_gmt":"2025-11-18T12:29:22","guid":{"rendered":"https:\/\/nyamsprod.com\/blog\/?p=3073"},"modified":"2025-11-18T14:29:23","modified_gmt":"2025-11-18T12:29:23","slug":"league-uri-toolkit-7-6-is-out","status":"publish","type":"post","link":"https:\/\/nyamsprod.com\/blog\/league-uri-toolkit-7-6-is-out\/","title":{"rendered":"League URI Toolkit 7.6 is out"},"content":{"rendered":"\n<p>I am very happy to announce that the League URI toolkit for PHP developers 7.6 has been released!<\/p>\n\n\n\n<p>If you\u2019re new to the toolkit,\u00a0you may want to start with its\u00a0<a href=\"https:\/\/uri.thephpleague.com\/\" target=\"_blank\" rel=\"noopener\" title=\"The League PHP URI Toolkit\">homepage<\/a>\u00a0to get an overview of what it can do for you.\u00a0The toolkit is made up, currently, of four packages,\u00a0each focused on making URI handling in PHP predictable,\u00a0consistent,\u00a0and developer-friendly.<\/p>\n\n\n\n<p>This release includes many new features and improvements.&nbsp;Rather than detailing each&nbsp;change here\u2014something the individual package CHANGELOG files already cover thoroughly\u2014I\u2019ll&nbsp;highlight a selection of the most notable additions and fixes:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"php85\">PHP8.5<\/h2>\n\n\n\n<p>A new package,&nbsp;<code>uri-polyfill<\/code>,&nbsp;has been introduced to bring PHP\u2019s new URI extension capabilities&nbsp;to older PHP versions,&nbsp;starting from&nbsp;<code>PHP 8.1<\/code>.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ncomposer install league\/uri-polyfill\n<\/pre><\/div>\n\n\n<p>On&nbsp;<code>PHP 8.5+<\/code>,&nbsp;the polyfill is not used\u2014even if it is installed.&nbsp;The native PHP URI extension will be&nbsp;used automatically.<\/p>\n\n\n\n<p>Support for&nbsp;<code>PHP 8.5<\/code>&nbsp;has now landed across all URI packages.&nbsp;They work out of the box on the latest&nbsp;PHP version without deprecations and include seamless support for the new URI extension.&nbsp;The packages do not require the extension to function,&nbsp;but when it\u2019s available,&nbsp;they will integrate with it automatically.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"uri-package\">URI package<\/h2>\n\n\n\n<p>The&nbsp;<code>league\\uri<\/code>&nbsp;package has now:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>a dedicated&nbsp;<code>League\\Uri\\Urn<\/code>&nbsp;object to improve support for URN;<\/li>\n\n\n\n<li>the&nbsp;<code>League\\Uri\\UriTemplate<\/code>&nbsp;class can now generate PHP Native URI with URI resolution built-in;<\/li>\n\n\n\n<li>URI validation has been improved with:\n<ul class=\"wp-block-list\">\n<li>full validation of&nbsp;<code>mailto<\/code>&nbsp;and&nbsp;<code>blob<\/code>&nbsp;URIs;<\/li>\n\n\n\n<li>improved component-based validation for a broader range of scheme URI;<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>The&nbsp;<code>League\\Uri\\Uri<\/code>&nbsp;class exposes more information around the URI and allows a range of new string representations.<\/li>\n<\/ul>\n\n\n\n<p><em>While still present the&nbsp;<code>BaseUri<\/code>&nbsp;class is deprecated and will be removed from the package in the next major version. It is recommended to use the&nbsp;<code>Uri<\/code>&nbsp;class instead as most of its feature has been backported to it.<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"uri-components-package\">URI components package<\/h2>\n\n\n\n<p>The&nbsp;<code>league\/uri-components<\/code>&nbsp;package introduces a new&nbsp;<code>TextDirective<\/code>&nbsp;class designed to enhance&nbsp;text-range highlighting within supported browsers.<\/p>\n\n\n\n<p>The&nbsp;<code>League\\Uri\\Modifier<\/code>&nbsp;has been enhanced to support modification of the most widely used URI&nbsp;objects in the PHP ecosystem.&nbsp;It now works seamlessly with any&nbsp;<code>PSR-7<\/code>&nbsp;URI implementation,&nbsp;PHP\u2019s native Uri object,&nbsp;and League URI objects.&nbsp;With more than 60 modification methods available,&nbsp;it offers reliable,&nbsp;standard-compliant URI transformations with no loss of information.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"migration-guide\">Migration Guide<\/h2>\n\n\n\n<p>The documentation now reflects all the latest enhancements and new features.&nbsp;And because this isn\u2019t&nbsp;a major release,&nbsp;you can enjoy the improvements without needing a migration guide.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"give-me-some-code\">Give Me Some Code<\/h2>\n\n\n\n<p>If everything I\u2019ve explained so far feels too complex or hard to relate to,&nbsp;here\u2019s a concrete&nbsp;example to show what\u2019s now possible with the new versions:<\/p>\n\n\n\n<p>First,&nbsp;require the new&nbsp;<code>uri-polyfill<\/code>&nbsp;package and require or update the&nbsp;<code>uri-components<\/code>&nbsp;package.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ncomposer require league\/uri-polyfill league\/uri-components\n<\/pre><\/div>\n\n\n<p><em>By installing or upgrading the&nbsp;<code>uri-components<\/code>&nbsp;you are also installing\/upgrading the&nbsp;<code>uri<\/code>&nbsp;package.<\/em><\/p>\n\n\n\n<p>Then,&nbsp;copy\/paste the following script locally:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nuse League\\Uri\\Components\\FragmentDirectives\\TextDirective;\nuse League\\Uri\\Modifier;\nuse League\\Uri\\UriTemplate;\n\nrequire &#039;vendor\/autoload.php&#039;;\n\n$uriTemplate = new UriTemplate(&#039;{package}\/{version}&#039;, &#x5B;&#039;version&#039; =&gt; &#039;7.0&#039;]);\n$url = $uriTemplate-&gt;expandToUrl(&#x5B;&#039;package&#039; =&gt; &#039;polyfill&#039;], &#039;https:\/\/uri.thephpleague.com&#039;);\n\/\/ $url is a Uri\\WhatWg\\Url instance\n\n$modifier = Modifier::wrap($url)\n    -&gt;addTrailingSlash()\n    -&gt;withFragment(new TextDirective(\n        start: &quot;This package backports&quot;,\n        end: &quot;PHP documentation website.&quot;\n    ));\n\n$newUri = $modifier-&gt;unwrap();\n\/\/ $newUri is a Uri\\WhatWg\\Url instance\necho $newUri-&gt;toAsciiString(), PHP_EOL; \n\/\/we are calling a method on the Uri\\WhatWg\\Url\n\/\/if you are on PHP8.5 it will be the native object\n\/\/on PHP8.4- it will be the installed uri-polyfill\n<\/pre><\/div>\n\n\n<p>Finally,&nbsp;click or paste the generated link in your favorite browser!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"last-but-not-least\">Last but not least<\/h2>\n\n\n\n<p>Since this is a one-person project,&nbsp;if you notice anything that could be improved in the&nbsp;package or its documentation,&nbsp;please consider opening an issue or submitting a pull request.&nbsp;The URI packages are open-source under the MIT License,&nbsp;and contributions of all kinds are&nbsp;welcome and fully credited.&nbsp;Whether it\u2019s reporting a bug,&nbsp;requesting or implementing a&nbsp;missing feature,&nbsp;fixing a typo,&nbsp;improving the documentation,&nbsp;or sponsoring the&nbsp;project,&nbsp;your support makes a real difference.<\/p>\n\n\n\n<p>Happy coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The new URI Toolkit for PHP developers is out with full support for PHP8.5, improved URI validation and manipulation.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[5],"tags":[135,870,868,412,872,869,794,871,820,867],"class_list":["post-3073","post","type-post","status-publish","format-standard","hentry","category-web","tag-css","tag-fragment-text-directives","tag-mailto","tag-php","tag-php8-5","tag-text-directives","tag-uri","tag-uri-validation","tag-uri-template","tag-urn"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/nyamsprod.com\/blog\/wp-json\/wp\/v2\/posts\/3073","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nyamsprod.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nyamsprod.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nyamsprod.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nyamsprod.com\/blog\/wp-json\/wp\/v2\/comments?post=3073"}],"version-history":[{"count":5,"href":"https:\/\/nyamsprod.com\/blog\/wp-json\/wp\/v2\/posts\/3073\/revisions"}],"predecessor-version":[{"id":3079,"href":"https:\/\/nyamsprod.com\/blog\/wp-json\/wp\/v2\/posts\/3073\/revisions\/3079"}],"wp:attachment":[{"href":"https:\/\/nyamsprod.com\/blog\/wp-json\/wp\/v2\/media?parent=3073"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nyamsprod.com\/blog\/wp-json\/wp\/v2\/categories?post=3073"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nyamsprod.com\/blog\/wp-json\/wp\/v2\/tags?post=3073"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}