Skip to content

efureev/php-dsn

Repository files navigation

DSN Parser

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

About

DSN Parser

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages