I enjoy CakePHP’s structure and methods so much that I have started using it for my non-database driven projects and for prototyping big projects.
However, when no database is present CakePHP throws a warning that it can’t connect to the database. The solution is to create a dummy database connection to convince CakePHP that all is ok. And, it’s as simple as this:
Create a new folder app/models/datasources/dbo
Create a new file at app/models/datasources/dbo/dbo_dummy_db.php and add the following:
1 2 3 4 5 6 7 | <?php class DboDummyDb extends DboSource { function connect() { $this->connected = true; return $this->connected; } } |
In your app/config/database.php find the default connection array – a line that starts $default = array
and replace the line for the driver from
'driver' => 'mysql',
to
'driver' => 'dummy_db',
And that’s all there is to using CakePHP without a database.