Cakephp V2 without a database (Fixed)

by Primordial

This bug has now been fixed

A very simple explanation on how to get around the topical bug in CakePHP V2 and use it without a database.

When you want to use CakePHP without a database create the file /app/Model/Datasource/DummySource.php with the following content

class DummySource extends DataSource {

    function connect() {
        $this->connected = true;
        return $this->connected;

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

    function isConnected() {

        return true;

Next update your /app/Config/database.php file altering the ‘default’ array to include a datasource that reads
'datasource' => 'DummySource'

Don’t forget, for every model you create include the property

$useTable = false

That’s all folks.


More on Articles



  • Primordial posted on 01/19/12 03:28:04 PM
    Thanks for the constructve feedback.

    When you install cake it prompts for a DB connection, this is a workaround I used. Can you elaborate on your comment please?
  • lorenzo posted on 01/19/12 03:11:07 PM
    This does not make any sense at all, CakePHP 2.0 will not try to perform any datbase connection unless you request it to do so. I'm leaving this article for future reference and to avoid confusion from our users.
login to post a comment.