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

Uri Template Laravel Package

guzzlehttp/uri-template

RFC 6570 URI Template expansion for PHP. Build URLs by substituting variables into templates, handling reserved characters, query strings, and fragments. Lightweight Guzzle component installable via Composer, with tests and changelog included.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Dynamic API Client Development: Enables consistent, standards-compliant URL construction for API clients (e.g., Laravel HTTP clients, SDKs) by reliably expanding URI templates with variables, reducing manual string concatenation errors.
  • Build vs. Buy: Justifies buying this lightweight, RFC 6570-compliant solution over building custom URI templating logic, especially for teams prioritizing maintainability and standards compliance.
  • Roadmap for API-Driven Features: Supports future-proofing of API integrations (e.g., GraphQL endpoints, OAuth flows) where dynamic path/query parameters are critical.
  • Edge-Case Handling in Queries: Addresses technical debt in query builders (e.g., Eloquent, custom query logic) where empty-string variables or non-finite floats could break operator parsing, improving robustness for:
    • Conditional filtering (e.g., where('status', '=', $emptyVar)).
    • Pagination with dynamic limits (e.g., ?limit={$limit} where $limit = INF).
    • Complex joins or subqueries with runtime variables.

When to Consider This Package

Adopt if:

  • Your Laravel application constructs dynamic URLs (e.g., API endpoints, redirects, webhook URLs) using variable substitution and requires RFC 6570 compliance for consistency.
  • You need to expand URI templates with variables that may include:
    • Empty strings (e.g., ?{+filter} where filter = "").
    • Non-finite floats (e.g., INF, NAN) in query parameters.
    • Complex nested arrays or reserved characters (e.g., ?{&query} with array inputs).
  • You’re using Guzzle HTTP clients or Laravel’s HTTP facade and want to avoid reinventing URI templating logic.
  • Your team values standards compliance (RFC 6570) and minimal dependency overhead for URL construction.
  • You’re migrating from custom string concatenation or regex-based URL building to a more maintainable solution.

Look elsewhere if:

  • Your URLs are static with no variable expansion (e.g., hardcoded routes).
  • You’re using non-PHP backends (e.g., Node.js, Python) or PHP frameworks with built-in URI templating (e.g., Symfony’s UrlGenerator).
  • Your use case involves non-HTTP URIs (e.g., file paths, database connections) where URI templates aren’t applicable.
  • You prioritize maximum performance and can tolerate edge-case bugs in exchange for avoiding a dependency.
  • Your project does not use Composer or cannot accommodate MIT-licensed packages.

How to Pitch It (Stakeholders)

For Executives: *"This package resolves two critical gaps in our API and query infrastructure:

  1. Reliable URL construction: Ensures dynamic API endpoints (e.g., /users?{+filter}) work correctly even with empty variables or edge-case values like INF, reducing flaky integrations in [feature area, e.g., ‘partner APIs’ or ‘user dashboards’].
  2. Standards compliance: Aligns with RFC 6570 for URI templating, future-proofing our HTTP tooling and avoiding custom, error-prone logic. It’s a low-risk, high-reward upgrade—no code changes required, just a drop-in fix for consistent URL handling. Teams using dynamic queries or API clients will see immediate stability gains."*

For Engineering: *"Why upgrade to guzzlehttp/uri-template v1.0.7?

  • Fixes operator omission: Empty-string variables (e.g., ?{+var} with var = "") now preserve the + operator, preventing broken query strings in dynamic filters.
  • Handles PHP 8.5 floats: Non-finite values (INF, NAN) no longer trigger warnings, cleaning up logs in numerical workflows (e.g., analytics, financial APIs).
  • RFC 6570 compliance: Ensures consistent URI templating across the codebase, reducing bugs in API clients and HTTP tooling.

Action: If you’re using:

  • Dynamic URL generation (e.g., route('api.users', ['filter' => $input])),
  • Guzzle HTTP clients, or
  • Query strings with operators (+, &, |), test this update. No changes needed—just composer require guzzlehttp/uri-template. Focus on edge cases where variables might be empty or non-finite floats."*

For Developers: *"Key improvements in v1.0.7:

  1. Empty-string safety: ?{+var} with var = "" now expands to ?+var= (previously ?var=), fixing broken query operators.
  2. PHP 8.5 float fixes: No more warnings for INF/NAN in URLs (e.g., ?limit=INF).
  3. Query string accuracy: Nested arrays and reserved characters are handled per RFC 6570.

How to use:

use GuzzleHttp\UriTemplate;

// Expand a template
$template = new UriTemplate('/users?{+filter}');
$url = $template->expand(['filter' => '']); // Now: '/users?+filter='

When to care:

  • You’ve seen ?filter= instead of ?+filter= in logs.
  • PHP 8.5 warnings appear for INF/NAN in URLs.
  • You’re building API clients or dynamic routes and want RFC-compliant templating."*
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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky