PHPackages                             ad7six/dsn - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ad7six/dsn

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

ad7six/dsn
==========

A utility for parsing and generating service DSNs

0.4.0(11y ago)19610.6k↓29%116MITPHPPHP &gt;=5.4.0

Since Feb 4Pushed 3y ago1 watchersCompare

[ Source](https://github.com/AD7six/php-dsn)[ Packagist](https://packagist.org/packages/ad7six/dsn)[ RSS](/packages/ad7six-dsn/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (8)Used By (6)

PHP DSN #ARCHIVED#
==================

[](#php-dsn-archived)

A utility for parsing and generating service DSNs

What is a DSN?
--------------

[](#what-is-a-dsn)

A [data source name](http://en.wikipedia.org/wiki/Data_source_name) (DSN) is a string which defines how to connect to a service. Since it's a string, it's portable, not language or implementation dependent and anything capable of parsing it can know how to connect to the service it points at.

What does this repo do?
-----------------------

[](#what-does-this-repo-do)

This repo only provides a means of converting a DSN string into an array and vice versa.

Wrapper classes?
----------------

[](#wrapper-classes)

When using a wrapper class, this repo provides an array *in the format expected* by a particular consumer. So for example, the CakePHP wrapper classes provide arrays in the format the framework understands for a given DSN string.

Basic usage
-----------

[](#basic-usage)

The main dsn class implements a parse function which returns a dsn instance:

```
use \AD7six\Dsn\Dsn;

$url = $_ENV['SOME_SERVICE_URL'];
$dsn = Dsn::parse($url);

```

The class of the returned object is dependent upon the scheme of the service url, for example:

```
// $dsn is an instance of \AD7six\Dsn\Db\MysqlDsn;
$dsn = Dsn::parse('mysql://host/dbname');

// $dsn is an instance of \AD7six\Dsn\Db\SqliteDsn;
$dsn = Dsn::parse('sqlite:///path/to/name.db');

```

For unknown schemes - the an instance of the called class is returned. This also means that a more specific instance can be obtained by using a less-generic class where appropriate:

```
// $dsn is an instance of \AD7six\Dsn\Dsn;
$dsn = Dsn::parse('newdb://host/dbname');

// $dsn is an instance of \AD7six\Dsn\DbDsn;
$dsn = DbDsn::parse('newdb://host/dbname');

```

In all of the above cases, the returned instance is the "raw" dsn data:

```
// $dsn is an instance of \AD7six\Dsn\Db\MysqlDsn;
$dsn = Dsn::parse('mysql://host/dbname');

$dsn->toArray();
[
	'scheme' => 'mysql',
	'host' => 'host',
	'port' => 3306,
	'database' => 'dbname'
]

```

If the behavior of the raw dsn needs to be modified - use a wrapper implementation

References
----------

[](#references)

[12 factor applications](http://12factor.net/)

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity46

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~83 days

Recently: every ~94 days

Total

6

Last Release

4070d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/64bf8425f779c4ff29be15dbccca72c7753719e7a3eca4c24cf5ca4ec515e695?d=identicon)[AD7six](/maintainers/AD7six)

---

Top Contributors

[![AD7six](https://avatars.githubusercontent.com/u/33387?v=4)](https://github.com/AD7six "AD7six (111 commits)")[![ollietreend](https://avatars.githubusercontent.com/u/7735945?v=4)](https://github.com/ollietreend "ollietreend (4 commits)")[![josegonzalez](https://avatars.githubusercontent.com/u/65675?v=4)](https://github.com/josegonzalez "josegonzalez (1 commits)")[![mathop](https://avatars.githubusercontent.com/u/392130?v=4)](https://github.com/mathop "mathop (1 commits)")[![slywalker](https://avatars.githubusercontent.com/u/54266?v=4)](https://github.com/slywalker "slywalker (1 commits)")[![Suven](https://avatars.githubusercontent.com/u/465894?v=4)](https://github.com/Suven "Suven (1 commits)")

### Embed Badge

![Health badge](/badges/ad7six-dsn/health.svg)

```
[![Health](https://phpackages.com/badges/ad7six-dsn/health.svg)](https://phpackages.com/packages/ad7six-dsn)
```

###  Alternatives

[swissup/module-slick-carousel

the last carousel you'll ever need for magento2

1020.8k1](/packages/swissup-module-slick-carousel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
