public static function init($config = null)
	{
		$defaults = [
			'driver'	    => 'mysql',
			'host'		    => 'localhost',
			'database'	    => 'mysql',
			'username'	    => 'root',
			'password'	    => null,
			'log_queries'   => true,
			'charset'	    => 'utf8',
			'collation'	    => 'utf8_unicode_ci',
			'prefix'	    => null
		];

		$capsule = new Capsule;

		if (is_string($config)) {
			$config = self::parseDsn($config);
		}

		if (is_array($config)) {
			// missing 'driver' key, so it must be an array of arrays
			if (!array_key_exists('driver', $config)) {
				// if we have an array of connections, iterate through them.
				// Cnnections should be stored in the form of name => conn_info
				foreach ($config as $connection_name => $connection_info) {
					// if it's a dsn string, then parse it
					if (is_string($connection_info)) {
						$connection_info = self::parseDsn($connection_info);
					}

					// now merge it into our options
					$options[$connection_name] = array_merge($defaults, $connection_info);
				}
			} else {
				$options['default'] = array_merge($defaults, $config);
			}
		} else {
			$options['default'] = $defaults;
		}

		// add each connection, then set as global and boot
		foreach ($options as $name => $info) {
			$capsule->addConnection($info, $name);
			self::$driver[$name] = $info['driver'];
		}

		$capsule->setAsGlobal();
		$capsule->bootEloquent();

		// determine if we should log queries or not
		foreach ($options as $name => $info) {
			// make sure we use FALSE to disable queries, otherwise it'll just default to logging queries
			if (isset($info['log_queries']) && $info['log_queries'] === false) {
				Capsule::connection($name)->disableQueryLog();
			} else {
				Capsule::connection($name)->enableQueryLog();
			}
		}
	}
public static function init($config = null)
	{
		$defaults = [
			'driver'	    => 'mysql',
			'host'		    => 'localhost',
			'database'	    => 'mysql',
			'username'	    => 'root',
			'password'	    => null,
			'log_queries'   => true,
			'charset'	    => 'utf8',
			'collation'	    => 'utf8_unicode_ci',
			'prefix'	    => null
		];

		$capsule = new Capsule;

		if (is_string($config)) {
			$config = self::parseDsn($config);
		}

		if (is_array($config)) {
			// missing 'driver' key, so it must be an array of arrays
			if (!array_key_exists('driver', $config)) {
				// if we have an array of connections, iterate through them.
				// Cnnections should be stored in the form of name => conn_info
				foreach ($config as $connection_name => $connection_info) {
					// if it's a dsn string, then parse it
					if (is_string($connection_info)) {
						$connection_info = self::parseDsn($connection_info);
					}

					// now merge it into our options
					$options[$connection_name] = array_merge($defaults, $connection_info);
				}
			} else {
				$options['default'] = array_merge($defaults, $config);
			}
		} else {
			$options['default'] = $defaults;
		}

		// add each connection, then set as global and boot
		foreach ($options as $name => $info) {
			$capsule->addConnection($info, $name);
			self::$driver[$name] = $info['driver'];
		}

		$capsule->setAsGlobal();
		$capsule->bootEloquent();

		// determine if we should log queries or not
		foreach ($options as $name => $info) {
			// make sure we use FALSE to disable queries, otherwise it'll just default to logging queries
			if (isset($info['log_queries']) && $info['log_queries'] === false) {
				Capsule::connection($name)->disableQueryLog();
			} else {
				Capsule::connection($name)->enableQueryLog();
			}
		}
	}
public static function init ( $ config = null ) { $ defaults = [ 'driver' => 'mysql' , 'host' => 'localhost' , 'database' => 'mysql' , 'username' => 'root' , 'password' => null , 'log_queries' => true , 'charset' => 'utf8' , 'collation' => 'utf8_unicode_ci' , 'prefix' => null ] ; $ capsule = new Capsule ; if ( is_string ( $ config ) ) { $ config = self :: parseDsn ( $ config ) ; } if ( is_array ( $ config ) ) { // missing 'driver' key, so it must be an array of arrays if ( ! array_key_exists ( 'driver' , $ config ) ) { // if we have an array of connections, iterate through them. // Cnnections should be stored in the form of name => conn_info foreach ( $ config as $ connection_name => $ connection_info ) { // if it's a dsn string, then parse it if ( is_string ( $ connection_info ) ) { $ connection_info = self :: parseDsn ( $ connection_info ) ; } // now merge it into our options $ options [ $ connection_name ] = array_merge ( $ defaults , $ connection_info ) ; } } else { $ options [ 'default' ] = array_merge ( $ defaults , $ config ) ; } } else { $ options [ 'default' ] = $ defaults ; } // add each connection, then set as global and boot foreach ( $ options as $ name => $ info ) { $ capsule -> addConnection ( $ info , $ name ) ; self :: $ driver [ $ name ] = $ info [ 'driver' ] ; } $ capsule -> setAsGlobal ( ) ; $ capsule -> bootEloquent ( ) ; // determine if we should log queries or not foreach ( $ options as $ name => $ info ) { // make sure we use FALSE to disable queries, otherwise it'll just default to logging queries if ( isset ( $ info [ 'log_queries' ] ) && $ info [ 'log_queries' ] === false ) { Capsule :: connection ( $ name ) -> disableQueryLog ( ) ; } else { Capsule :: connection ( $ name ) -> enableQueryLog ( ) ; } } }
Initialize the connection to the database.

@param null $config
Initialize the connection to the database .