Reputation: 8920
I am new to Cakephp, I am trying to install it. I extract everything and create the needed files/folders, now there is the following error:
Warning (2): include_once(C:\xampp\htdocs\TravelBuddy\app\Config\database.php): failed to open stream: No such file or directory [CORE\Cake\Model\ConnectionManager.php, line 67]
Warning (2): include_once() [function.include]: Failed opening 'C:\xampp\htdocs\TravelBuddy\app\Config\database.php' for inclusion (include_path='C:\xampp\htdocs\TravelBuddy\lib;.;C:\xampp\php\PEAR') [CORE\Cake\Model\ConnectionManager.php, line 67]
The file database.php
does not exists. Do I have to create it?
Here is the code of ConnectionManager
where the problem is:
protected static function _init() {
include_once APP . 'Config' . DS . 'database.php';
if (class_exists('DATABASE_CONFIG')) {
self::$config = new DATABASE_CONFIG();
}
self::$_init = true;
}
Upvotes: 1
Views: 7120
Reputation: 1279
Check and make sure the database.php file is committed in your git repo. Checkout the .gitignore file.
Upvotes: 0
Reputation: 2856
To avoid the given error you should do
if (class_exists('DATABASE_CONFIG', FALSE)) {
self::$config = new DATABASE_CONFIG();
}
i was struggling with same problem, but if the class didn't exist it should perform the remaining operation, and not giving me a fatal error.
http://www.php.net/manual/en/function.class-exists.php
Upvotes: 0
Reputation: 35973
create inside: app/Config
a file called database.php
now you need to configure your database connection like:
<?php
class DATABASE_CONFIG {
public $default = array (
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'yourusermysql',
'password' => 'passwordmysql',
'database' => 'nameofdatabase',
'prefix' => ''
);
public $test = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'user',
'password' => 'password',
'database' => 'test_database_name',
'prefix' => '',
//'encoding' => 'utf8',
);
}
?>
Upvotes: 2