https://github.com/utopia-php/dsn
Lite & fast micro PHP library for handling Data Source Names (DSNs) that is **easy to use**.
https://github.com/utopia-php/dsn
Last synced: about 2 months ago
JSON representation
Lite & fast micro PHP library for handling Data Source Names (DSNs) that is **easy to use**.
- Host: GitHub
- URL: https://github.com/utopia-php/dsn
- Owner: utopia-php
- License: mit
- Created: 2022-10-25T18:52:50.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-07T02:02:00.000Z (about 1 year ago)
- Last Synced: 2025-03-27T22:11:08.028Z (2 months ago)
- Language: PHP
- Size: 36.1 KB
- Stars: 6
- Watchers: 6
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Utopia DSN

[](https://appwrite.io/discord)Utopia DSN library is simple and lite library for parsing and managing Data Source Names or DSNs. This library aims to be as simple and easy to learn and use as possible. This library is maintained by the [Appwrite team](https://appwrite.io).
Although the library was built for the [Utopia Framework](https://github.com/utopia-php/framework) project, it is completely independent, **dependency-free** and can be used with any other PHP project or framework.
## Getting Started
Install using composer:
```bash
composer require utopia-php/dsn
``````php
getScheme(); // mariadb
$user = $dsn->getUser(); // user
$password = $dsn->getPassword(); // password
$host = $dsn->getHost(); // localhost
$port = $dsn->getPort(); // 3306
$path = $dsn->getPath(); // database
$query = $dsn->getQuery(); // charset=utf8&timezone=UTC
$charset = $dsn->getParam('charset') // utf8
$timezone = $dsn->getParam('timezone') // UTC
```## Tests
To run all unit tests, use the following Docker command:
```bash
docker run --rm -v $(pwd):$(pwd):rw -w $(pwd) php:8.0-cli-alpine sh -c "vendor/bin/phpunit --configuration phpunit.xml tests"
```To run the linter, use the following composer command:
```bash
composer lint# Or if you do not have composer installed
docker run --rm -v $(pwd):$(pwd):rw -w $(pwd) composer sh -c "composer lint"
```To fix the errors raised by the linter, use the following command:
```php
composer format# Or if you do not have composer installed
docker run --rm -v $(pwd):$(pwd):rw -w $(pwd) composer sh -c "composer format"
```## System Requirements
Utopia DSN requires PHP 8.0 or later. We recommend using the latest PHP version whenever possible.
## Copyright and license
The MIT License (MIT) [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php)