Weave 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

Php Domain Parser Laravel Package

jeremykendall/php-domain-parser

Parse, validate, and normalize domains, subdomains, and suffixes using the Public Suffix List. Extract registrable domain vs. subdomain, handle IDNs and edge cases, and keep parsing rules current via PSL updates—ideal for URL processing, cookies, and security checks.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Feature Development:
    • Absolute Domain Handling: Enables precise validation and manipulation of absolute domains (e.g., https://example.com vs. example.com) for features like:
      • HTTPS enforcement (e.g., rejecting non-absolute URLs in security-sensitive forms).
      • Canonical URL normalization (e.g., stripping http:///https:// for consistency in analytics).
      • Middleware for domain-based routing (e.g., redirecting example.com to www.example.com).
    • Conditional Domain Building: Supports dynamic domain construction (e.g., DomainName::when($isSecure, fn() => 'https://')->parse()) for:
      • A/B testing (e.g., routing users to a.example.com or b.example.com based on conditions).
      • Multi-tenant SaaS (e.g., tenant1.yourservice.com with runtime subdomain generation).
    • Private Suffix Resolution: Fixes edge cases for internal domains (e.g., *.private.corp) critical for:
      • Enterprise SaaS (e.g., validating custom subdomains in corporate environments).
      • Local development (e.g., *.localhost or *.test without conflicts).
  • Roadmap Prioritization:
    • Security Hardening: Absolute domain checks reduce risks of SSRF or open redirects by validating full URLs.
    • Compliance: Improved private suffix handling aids GDPR/CCPA domain-scoped consent management.
    • Performance: Local cache refresh requirement (6.4.0) is a one-time cost for critical fixes (e.g., private domains).
  • Build vs. Buy:
    • Buy: Now even stronger for absolute domain use cases (e.g., URL validation, HTTPS enforcement).
    • Build: Only if you need custom DNS resolution (e.g., real-time WHOIS) or non-PSL domain logic (e.g., proprietary naming schemes).

When to Consider This Package

  • Adopt if:
    • You handle absolute URLs (e.g., user uploads, API endpoints, or redirects) and need RFC-compliant parsing.
    • Your app requires conditional domain construction (e.g., dynamic subdomains or protocol switching).
    • You manage private/internal domains (e.g., *.corp, *.localhost) and need wildcard subdomain support.
    • You’re upgrading from PHP 7.x and want modern type hints/return types (6.4.0+).
    • Cache refresh is acceptable as a one-time migration step (critical for private suffix fixes).
  • Look elsewhere if:
    • You need real-time DNS validation (e.g., checking domain availability; use a dedicated API like whois.xml).
    • Your use case involves non-standard domain formats (e.g., IP addresses as domains; use parse_url() + custom logic).
    • You cannot refresh the PSL cache (e.g., serverless environments with ephemeral storage; consider a self-hosted PSL).
    • You require IDN validation beyond Unicode normalization (e.g., Punycode-specific rules; pair with rubix/ml-idn).

How to Pitch It (Stakeholders)

For Executives: *"The latest update (6.4.0) supercharges this package for absolute domain handling and private/internal domains, enabling us to:

  • Block malicious redirects by validating full URLs (e.g., http:// vs. https://).
  • Support enterprise customers with custom subdomains (e.g., *.private.corp) without custom code.
  • Reduce fraud by dynamically constructing domains for A/B tests or multi-tenancy. This is a low-effort upgrade (one-time cache refresh) with high rewards—used by 1,200+ projects, MIT-licensed, and now even more robust for security and compliance. For example, we could auto-enforce HTTPS for all user-uploaded links or validate corporate domains in our SaaS."*

For Engineering: *"6.4.0 adds critical features for absolute domains and private suffixes, with zero breaking changes (except a required PSL cache refresh):

  • New Methods:
    • withRootLabel()/withoutRootLabel(): Strip/add http:///https:// for URL normalization.
    • isAbsolute(): Validate full URLs (e.g., reject example.com if you need https://example.com).
    • when(): Build domains conditionally (e.g., DomainName::when($isSecure)->parse()).
  • Fixes:
    • Absolute domains now resolve correctly (no more exceptions for https://example.com).
    • Private suffixes (e.g., *.private.corp) work with wildcard subdomains.
  • Upgrade Path:
    composer update jeremykendall/php-domain-parser
    php artisan domain-parser:refresh  # Laravel-specific; adjust for raw PHP
    

Use Cases:

  • Replace parse_url() + regex for HTTPS enforcement in forms.
  • Validate custom subdomains in SaaS (e.g., tenant1.yourservice.com).
  • Dynamic routing based on domain conditions (e.g., when($isAdmin)->subdomain('admin')). Trade-offs:
  • Cache refresh required (one-time, ~5s for large PSLs).
  • No DNS resolution (still just parsing). Proposal: Add to composer.json and use DomainName::parse($url)->isAbsolute() in validation middleware or when() for dynamic domains."*
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.
thuraaung2493/laravel-rulecraft
cyberwizard/schedule-catchup
livetennisapi/livetennisapi-laravel
roundly-consulting/notifications-for-laravel
flightsadmin/bootstrap-starter-kit
lasserafn/laravel-intempus
likyly/sdk
tdt/input
coreation/php-shapefile
coreation/gisconverter
primix/widgets
primix/notifications
primix/actions
primix/tables
primix/details
primix/forms
primix/support
marcelgwerder/laravel-api-handler
firebrikdotcom/conveyor-laravel-broadcaster
kanata-php/conveyor-laravel-broadcaster