我在嘗試執行cake bake all
,但不起作用,因爲我認爲問題出在我的蛋糕項目的路徑上。當我嘗試執行終端上的命令時會拋出以下異常:Error: The datasource configuration "default" was not found in database.php
。文件database.php在這個路徑ExemploCake/app/Config/database.php
。Ubuntu + Lampp和CakePHP?
我使用的是:Ubuntu的使用LAMPP和CakePHP 2.7
配置爲database.php
<?php
class DATABASE_CONFIG {
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'root',
'password' => '',
'database' => 'cakePHP',
'prefix' => '',
'encoding' => 'utf8'
);
public $test = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'root',
'password' => '',
'database' => 'cakePHP',
'prefix' => '',
'encoding' => 'utf8'
);
}
?>
異常從app
文件夾
[email protected]:/opt/lampp/htdocs/ExemploCake/app/Console# ./cake bake all
Welcome to CakePHP v2.7.0 Console
---------------------------------------------------------------
App : app
Path: /opt/lampp/htdocs/ExemploCake/app/
---------------------------------------------------------------
Bake All
---------------------------------------------------------------
Error: Database connection "Mysql" is missing, or could not be created.
#0 /opt/lampp/htdocs/ExemploCake/lib/Cake/Model/ConnectionManager.php(105): DboSource->__construct(Array)
#1 /opt/lampp/htdocs/ExemploCake/lib/Cake/Console/Command/Task/ModelTask.php(952): ConnectionManager::getDataSource('default')
#2 /opt/lampp/htdocs/ExemploCake/lib/Cake/Console/Command/Task/ModelTask.php(889): ModelTask->getAllTables('default')
#3 /opt/lampp/htdocs/ExemploCake/lib/Cake/Console/Command/Task/ModelTask.php(979): ModelTask->listAll('default')
#4 /opt/lampp/htdocs/ExemploCake/lib/Cake/Console/Command/BakeShell.php(150): ModelTask->getName('default')
#5 /opt/lampp/htdocs/ExemploCake/lib/Cake/Console/Shell.php(444): BakeShell->all()
#6 /opt/lampp/htdocs/ExemploCake/lib/Cake/Console/ShellDispatcher.php(212): Shell->runCommand('all', Array)
#7 /opt/lampp/htdocs/ExemploCake/lib/Cake/Console/ShellDispatcher.php(66): ShellDispatcher->dispatch()
#8 /opt/lampp/htdocs/ExemploCake/app/Console/cake.php(47): ShellDispatcher::run(Array)
#9 {main}
在ubuntu上安裝mysql的最新版本 –