public static method

Add connection configurations to your app in config/bootstrap/connections.php

For example:

Connections::add('default', [
	'type' => 'database',
	'adapter' => 'MySql',
	'host' => 'localhost',
	'login' => 'root',
	'password' => '',
	'database' => 'my_blog'


Connections::add('couch', [
	'type' => 'http',
	'adapter' => 'CouchDb',
	'host' => '',
	'port' => 5984


Connections::add('mongo', [
	'type' => 'MongoDb',
	'database' => 'my_app'


  • string $name

    The name by which this connection is referenced. Use this name to retrieve the connection again using Connections::get(), or to bind a model to it using Model::$_meta['connection'].

  • array $config

    Contains all additional configuration information used by the connection, including the name of the adapter class where applicable (i.e. MySql), and typcially the server host/socket to connect to, the name of the database or other entity to use. Each adapter has its own specific configuration settings for handling things like connection persistence, data encoding, etc. See the individual adapter or data source class for more information on what configuration settings it supports. Basic / required options supported are:

    • 'type' string: The type of data source that defines this connection; typically a class or namespace name. Relational database data sources, use 'database', while CouchDB and other HTTP-related data sources use 'http', etc. For classes which directly extend lithium\data\Source, and do not use an adapter, simply use the name of the class, i.e. 'MongoDb'.
    • 'adapter' string: For types such as 'database' which are adapter-driven, provides the name of the adapter associated with this configuration.



Returns the final post-processed connection information, as stored in the internal configuration array used by Connections.


	public static function add($name, array $config = []) {
		$defaults = [
			'type'     => null,
			'adapter'  => null
		return static::$_configurations[$name] = $config + $defaults;