https://github.com/efureev/php-dsn
DSN Parser
https://github.com/efureev/php-dsn
dsn dsnparser php
Last synced: 5 months ago
JSON representation
DSN Parser
- Host: GitHub
- URL: https://github.com/efureev/php-dsn
- Owner: efureev
- License: mit
- Created: 2024-09-26T07:39:38.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-09-27T07:16:28.000Z (7 months ago)
- Last Synced: 2024-11-19T05:17:33.842Z (5 months ago)
- Topics: dsn, dsnparser, php
- Language: PHP
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# DSN Parser
[](https://github.com/efureev/php-dsn/actions/workflows/php.yml)
[](https://packagist.org/packages/efureev/dsn)
[](https://packagist.org/packages/efureev/dsn)
[](https://packagist.org/packages/efureev/dsn)
[](https://packagist.org/packages/efureev/dsn)
[](https://packagist.org/packages/efureev/dsn)
[](https://packagist.org/packages/efureev/dsn)## 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](https://datatracker.ietf.org/doc/html/rfc3986).## Kinds
### String DSN
Template: `://:@:/`
- `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: `:host=;port=;dbname=`- `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
```bash
composer require efureev/dsn "^1.0"
```## Test
```bash
composer test
```