Dsn

in package

Data Source Name (DSN), a reference to a path on a local or remote system with the ability to add parameters.

The format for the DSN is inspired by the PDO DSN format (https://www.php.net/manual/en/ref.pdo-mysql.connection.php) where you have a string containing Semicolon Separated Values (SSV), where each part is a key=value pair. Exception to this rule is the first entry in the string; this is the URI where the referenced Data Source is located.

A simple example can be a reference to your project folder:

file:///home/mvriel/project/src

Yet a more complex example may be a reference to a specific branch on a git repository:

git+https://github.com/phpDocumentor/phpDocumentor;path=/src;branch=release/3.0

In the example above we reference a git repository using the http protocol and as options we mention that the branch that we would like to parse is release/3.0 and in it we want to start at the path /src.

Properties

private$dsn  : string                

private$uri  : \League\Uri\Contracts\UriInterface                

private$parameters  : string[]                

Methods

Initializes the Dsn

public__construct(UriInterface $uri, string[] $parameters, string $dsn) : mixed

Parameters

$uri : UriInterface
$parameters : string[]
$dsn : string

Returns

mixed

publicstaticcreateFromString(string $dsn) : self

Parameters

$dsn : string

Returns

self

publicstaticcreateFromUri(UriInterface $uri[, string[] $parameters = [] ]) : self

Parameters

$uri : UriInterface
$parameters : string[] = []

Returns

self

Returns a string representation of the DSN.

public__toString() : string

Returns

string

Returns the scheme part of the DSN

publicgetScheme() : string|null

Returns

string|null

Returns the host part of the DSN

publicgetHost() : string

Returns

string

Returns the port part of the DSN

publicgetPort() : int|null

Returns

int|null

Returns the username part of the DSN

publicgetUsername() : string

Returns

string

Returns the password part of the DSN

publicgetPassword() : string

Returns

string

Returns the path part of the DSN

publicgetPath() : Path

Returns

Path

publicisWindowsLocalPath() : bool

Returns

bool

Returns the query part of the DSN

publicgetQuery() : string[]

Returns

string[]

Returns the parameters part of the DSN

publicgetParameters() : string[]

Returns

string[]

publicresolve(Dsn $baseDsn) : self

Parameters

$baseDsn : Dsn

Returns

self

publicwithPath(Path $path) : self

Parameters

$path : Path

Returns

self

validates and sets the parameters property

privatestaticparseParameters(string[] $parameters) : array

Parameters

$parameters : string[]

Returns

array

privatestaticparseParameter(string $part) : \Generator

Parameters

$part : string

Returns

\Generator