DSN Parser

Maintainers

👁 efureev

Package info

github.com/efureev/php-dsn

pkg:composer/efureev/dsn

Statistics

Installs: 2 024

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

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

Requires

  • php: ^8.2|^8.3|^8.4

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 22d82c1c8e8506de30be6fb62251db85f886a581

phputilitydsn

This package is auto-updated.

Last update: 2026-06-27 11:00:48 UTC


README

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

Description

There is no official DSN RFC. We have defined a DSN configuration string as using the following definition. The "URL looking" parts of a DSN is based from RFC 3986.

Kinds

String DSN

Template: <scheme>://<username>:<password>@<host>:<port>/<database>

  • http://localhost
  • 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

Parameters DSN

Template: <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

Install

For php >= 8.2

composer require efureev/dsn "^1.0"

Test

composer test