public static method

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

For example:

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


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


Connections::add('mongo', array('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), the server name and port or socket to connect to, and (typically) 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 by most adapters:

    • '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.
    • 'host' string: The host name that the database should connect to. Typically defaults to 'localhost'.
    • 'login' string: If the connection requires authentication, specifies the login name to use.
    • 'password' string: If the connection requires authentication, specifies the password to use.



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


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