efureev / dsn
DSN Parser
v1.0.1
2024-09-26 08:22 UTC
Requires
- php: ^8.2|^8.3|^8.4
Requires (Dev)
- phpstan/phpstan: ^1.12
- phpunit/phpunit: ^11.3
- squizlabs/php_codesniffer: ^3.10.3
README
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