efureev/dsn

DSN 解析器

v1.0.1 2024-09-26 08:22 UTC

This package is auto-updated.

Last update: 2024-09-27 07:16:31 UTC


README

PHP Package Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require Dependents

描述

没有官方的 DSN RFC。我们定义了一个 DSN 配置字符串,如下所示。DSN 的 "URL 查看部分" 基于 RFC 3986

类型

字符串 DSN

模板: <scheme>://<username>:<password>@<host>:<port>/<database>

  • https://
  • localhost:8080
  • https://examlple.com
  • examlple.com
  • http://127.0.0.1/foo/bar?key=value
  • memcached://127.0.0.1
  • memcached:///var/local/run/memcached.socket?weight=25
  • mysql://john:pass@localhost:3306/my_db
  • scheme:///var/local/run/memcached.socket?weight=25

参数 DSN

模板: <scheme>:host=<host>;port=<port>;dbname=<database>

  • mysql:host=localhost;dbname=example
  • ocdb://?Driver=ODBC+Driver+13+for+SQL+Server&server=localhost&database=WideWorldImporters&trusted_connection=Yes

安装

对于 php >= 8.2

composer require efureev/dsn "^1.0"

测试

composer test