How to use cakephp without a database

Cakephp

Posted on 25 Nov 15 by Vickey
  818



When we install cakephp in starting we see databse error on the home page.For complete installation we add our database details in cakephp\app\Config \database.php file

class DATABASE_CONFIG {

	public $default = array(
		'datasource' => 'Database/Mysql',
		'persistent' => false,
		'host' => 'localhost',
		'login' => 'root',
		'password' => 'password',
		'database' => 'my_db',
		'prefix' => '',
		//'encoding' => 'utf8',
	);

	public $test = array(
		'datasource' => 'Database/Mysql',
		'persistent' => false,
		'host' => 'localhost',
		'login' => 'user',
		'password' => 'password',
		'database' => 'test_database_name',
		'prefix' => '',
		//'encoding' => 'utf8',
	);
}

But because of some reason if you do not want to use any database in your website then you can do this by these below steps

1.Create 'DummyDatabase.php' file under 'cakephp\app\Model\Datasource' directory and addthe below code in this file

connected = true;
        return $this->connected;
    }

    function disconnect() {
        $this->connected = false;
        return !$this->connected;
    }

    function isConnected() {

        return true;
    }

}
?>

2.Now open your database file 'cakephp\app\Config\database.php' and replace code from 'datasource' => 'Database/Mysql' to 'datasource' => 'DummyDatabase'.

Now you can use cakephp app without a databse


If this post help you reduce time to develop, you can help me to maintain this website :)
www.000webhost.com