Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Zend Uri Laravel Package

zendframework/zend-uri

zend-uri is a PHP component for parsing, validating, normalizing, and building URIs. It supports common schemes, handles encoding and edge cases, and provides a consistent API for working with URLs in Zend Framework and standalone projects.

View on GitHub
Deep Wiki
Context7

Getting Started

This package provides a robust, RFC-compliant URI handling class (Zend\Uri\Uri) for validating, parsing, and manipulating Uniform Resource Identifiers. Since the package is archived and no longer actively maintained (last release: 2019), it’s primarily useful in legacy Zend Framework or Laminas projects, or if you specifically require its validation behavior. First steps:

  • Install via Composer: composer require zendframework/zend-uri
  • Import the class: use Zend\Uri\Uri;
  • Basic use case: validate a URI and normalize it:
    $uri = new Uri('http://example.com/foo?bar=baz');
    $isValid = $uri->isValid(); // true
    $normalized = $uri->toString(); // 'http://example.com/foo?bar=baz'
    

Implementation Patterns

  • Validation before processing: Use isValid() to sanitize user-provided URIs before use in redirects, API integrations, or SSO flows.
  • Component-level manipulation: Access/modify parts of the URI individually (scheme, host, path, query, fragment):
    $uri->setHost('api.example.com');
    $uri->setQueryParam('token', 'abc123');
    
  • Static factory usage: Avoid manual instantiation when building URIs from arrays or relative paths:
    $uri = Uri::factory('https://');
    $uri->setPath('/users');
    
  • Relative-to-absolute resolution: Combine a base URI with a relative URI using resolve():
    $base = new Uri('http://example.com/path/');
    $relative = new Uri('../other?q=1');
    $absolute = $base->resolve($relative)->toString(); // 'http://example.com/other?q=1'
    

Gotchas and Tips

  • ⚠️ Archived and unmaintained: Avoid in new projects unless strictly needed for compatibility. Consider migrating to laminas/laminas-uri (its official successor) which has ongoing security support and newer PHP compatibility.
  • 🧪 Strict parsing: It enforces RFC 3986 but may reject edge cases like IRIs (Internationalized Resource Identifiers) unless manually encoded ($uri->setEncoding('UTF-8') won’t automatically handle multibyte hosts—use idn_to_ascii() first for international domains).
  • 🔍 Query parameter quirks: setQueryParam() overwrites existing values—use addQueryParam() for appending (e.g., multi-value ?tag=1&tag=2).
  • 🛑 No PSR-7 compatibility: This is not PSR-7 compliant. Do not use it alongside guzzlehttp/psr7 unless you wrap it or convert manually.
  • 📦 Autoloading: Ensure Composer autoloading works—verify vendor/autoload.php is included, as PSR-4 rules require correct namespace mapping.
  • 🧩 Extensibility: Extend Uri to add custom scheme validation (e.g., myapp://) by overriding validate() in a subclass.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport