定制 snapflowio/dsn 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

snapflowio/dsn

最新稳定版本:v0.1.0

Composer 安装命令:

composer require snapflowio/dsn

包简介

A simple and lightweight library for parsing domains and DSN strings.

README 文档

README

A simple and lightweight library for parsing domains and DSN strings.

Installation

composer require snapflowio/parser

Quick Start

DSN Parsing

Parse Data Source Names (connection strings) for databases, APIs, and other services:

<?php

use Snapflow\Parser\DSN;

// Parse a database connection string
$dsn = new DSN('mysql://user:password@localhost:3306/myapp?charset=utf8mb4&timeout=30');

// Access connection details
echo $dsn->getScheme();    // mysql
echo $dsn->getUser();      // user
echo $dsn->getPassword();  // password
echo $dsn->getHost();      // localhost
echo $dsn->getPort();      // 3306
echo $dsn->getPath();      // myapp

// Get query parameters with optional defaults
echo $dsn->getParam('charset');           // utf8mb4
echo $dsn->getParam('timeout');           // 30
echo $dsn->getParam('pool_size', '10');   // 10 (default)

Domain Parsing

Parse domains using the Public Suffix List to extract TLD, registrable domain, and subdomains:

<?php

use Snapflow\Parser\Domain;

// Parse a domain with subdomain
$domain = new Domain('www.example.gov.ac');

// Extract domain components
echo $domain->get();              // www.example.gov.ac
echo $domain->getTLD();           // ac
echo $domain->getSuffix();        // gov.ac
echo $domain->getName();          // example
echo $domain->getRegisterable();  // example.gov.ac
echo $domain->getSub();           // www
echo $domain->getApex();          // example.gov.ac

// Check domain properties
echo $domain->isKnown();    // true (suffix exists in Public Suffix List)
echo $domain->isICANN();    // false
echo $domain->isPrivate();  // false
echo $domain->isTest();     // false

License

This library is available under the MIT License.

Copyright

Copyright (c) 2025 Snapflow

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-27