承接 xoops/regdom 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

xoops/regdom

Composer 安装命令:

composer require xoops/regdom

包简介

A robust domain parser for PHP, using the Mozilla Public Suffix List to determine the registrable domain and validate cookie domains per RFC 6265.

README 文档

README

alt XOOPS CMS

RegDom - Registered Domain Check in PHP

Object oriented PHP library for querying Mozilla's Public Suffix List to determine the registrable domain portion of URLs and validate cookie domains per RFC 6265. Adapted from Florian Sager's regdom library.

For more information on public suffixes, see publicsuffix.org.

Requirements

  • PHP 8.2 or later
  • ext-mbstring required
  • ext-intl recommended (for internationalized domain name support)

Installation

composer require xoops/regdom

Usage

Extracting the Registered Domain

use Xoops\RegDom\RegisteredDomain;

$regdom = new RegisteredDomain();

echo $regdom->getRegisteredDomain('https://www.google.com/');
// Output: google.com

echo $regdom->getRegisteredDomain('theregister.co.uk');
// Output: theregister.co.uk

var_dump($regdom->getRegisteredDomain('co.uk'));
// Output: NULL (co.uk is a public suffix, not a registrable domain)

// IDN support (requires ext-intl)
echo $regdom->getRegisteredDomain('www.münchen.de');
// Output: münchen.de

Cookie Domain Validation (RFC 6265)

use Xoops\RegDom\RegisteredDomain;

// Validates if a cookie domain is appropriate for a given host
RegisteredDomain::domainMatches('www.example.com', 'example.com');  // true
RegisteredDomain::domainMatches('example.com', 'com');              // false (public suffix)
RegisteredDomain::domainMatches('google.com', 'facebook.com');      // false (cross-domain)
RegisteredDomain::domainMatches('192.168.1.1', '192.168.1.1');      // false (IP addresses)

Querying the Public Suffix List

use Xoops\RegDom\PublicSuffixList;

$psl = new PublicSuffixList();

$psl->isPublicSuffix('com');        // true
$psl->isPublicSuffix('co.uk');      // true
$psl->isPublicSuffix('example.com'); // false

$psl->getPublicSuffix('www.example.co.uk'); // 'co.uk'

$psl->isException('www.ck'); // true (PSL exception rule)

Checking PSL Cache Status

$metadata = $psl->getMetadata();
// Returns: active_cache, last_updated, days_old, rule_counts, needs_update

Updating the Public Suffix List

composer run update-psl

Set the XOOPS_SKIP_PSL_UPDATE environment variable to skip automatic PSL updates during composer install/update (useful in CI or restricted networks).

Configuration

XOOPS_COOKIE_DOMAIN_USE_PSL

When defined and set to false, disables PSL-based validation in RegisteredDomain::domainMatches(). Defaults to true when undefined.

XOOPS_SKIP_PSL_UPDATE

Environment variable. When set (to any value), prevents automatic PSL download during Composer post-install/update hooks.

Development

composer install          # Install dependencies
composer ci               # Run all checks: lint + analyse + test
composer test             # Run PHPUnit tests
composer lint             # Check code style (PSR-12)
composer analyse          # Run PHPStan (level max)
composer fix              # Auto-fix code style issues

Credits

Reg-dom was written by Florian Sager, 2009-02-05, sager@agitos.de

Marcus Bointon's adapted code: https://github.com/Synchro/regdom-php

License

The PHP library code in this repository is licensed under the Apache License 2.0. See LICENSE.txt for the full Apache 2.0 license text.

The bundled Public Suffix List data/cache is derived from Mozilla's Public Suffix List and is available under the Mozilla Public License 2.0 (MPL-2.0). For details, see https://www.mozilla.org/en-US/MPL/2.0/ and https://publicsuffix.org/.

xoops/regdom 适用场景与选型建议

xoops/regdom 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.76k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 07 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「parser」 「domain」 「cookie」 「public」 「tld」 「suffix」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 xoops/regdom 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 xoops/regdom 我们能提供哪些服务?
定制开发 / 二次开发

基于 xoops/regdom 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 6.76k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 31
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: (Apache-2.0 OR MPL-2.0) 4b6313e34e5a110d62ea45bc2fa234da29af6f70
  • 更新时间: 2024-07-08