OSX機器運行MAMP。 CakePHP 2.2.1正確安裝和配置(這意味着當我瀏覽到Index.php文件時,我已經有了所有的綠色條,我已經完成了博客教程,並正在開發和運行腳手架的第二個應用程序)。現在我正在嘗試第一次烘烤。蛋糕控制檯2.2.1:烘烤錯誤
每菜譜(及其他),我裝蛋糕的全新副本到一個目錄(我的用戶目錄),然後把路徑變量在我的.bash_profile文件 export PATH="$PATH:/Users/p_scott/cake221/app/Console"
之後,我能夠進入終端,輸入cake
,然後打開控制檯。你可以看到,到目前爲止,我正在從app目錄調用控制檯。
我第一次嘗試運行cake bake
從終端使用-app參數並指定我的實踐應用程序的路徑。我第一次這樣做,我得到了以下
Welcome to CakePHP v2.2.1 Console
-------------
App : app
Path: /Applications/MAMP/htdocs/blog/app/
-------------
Interactive Bake Shell
---------------
[D]atabase Configuration
[M]odel
[V]iew
[C]ontroller
[P]roject
[F]ixture
[T]est case
[Q]uit
What would you like to Bake? (D/M/V/C/P/F/T/Q)
> c
--------------------
Bake Controller
Path: /Applications/MAMP/htdocs/blog/app/Controller/
--------------------
\Use Database Config: (default/test)
[default] >
不管是什麼,我把數據庫(如果我留空白,再次問我),但任何回答給了我以下錯誤:
Warning Error: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in [/Users/p_scott/cake221/lib/Cake/Model/Datasource/Database/Mysql.php, line 149]
Error: Database connection "SQLSTATE[HY000] [2002] No such file or directory" is missing, or could not be created.
#0 /Users/p_scott/cake221/lib/Cake/Model/Datasource/DboSource.php(260): Mysql->connect()
#1 /Users/p_scott/cake221/lib/Cake/Model/ConnectionManager.php(101): DboSource->__construct(Array)
#2 /Users/p_scott/cake221/lib/Cake/Console/Command/Task/ModelTask.php(906): ConnectionManager::getDataSource('default')
#3 /Users/p_scott/cake221/lib/Cake/Console/Command/Task/ControllerTask.php(396): ModelTask->getAllTables('default')
#4 /Users/p_scott/cake221/lib/Cake/Console/Command/Task/ControllerTask.php(419): ControllerTask->listAll(NULL)
#5 /Users/p_scott/cake221/lib/Cake/Console/Command/Task/ControllerTask.php(136): ControllerTask->getName()
#6 /Users/p_scott/cake221/lib/Cake/Console/Command/Task/ControllerTask.php(61): ControllerTask->_interactive()
#7 /Users/p_scott/cake221/lib/Cake/Console/Command/BakeShell.php(113): ControllerTask->execute()
#8 /Users/p_scott/cake221/lib/Cake/Console/Shell.php(393): BakeShell->main()
#9 /Users/p_scott/cake221/lib/Cake/Console/ShellDispatcher.php(201): Shell->runCommand(NULL, Array)
#10 /Users/p_scott/cake221/lib/Cake/Console/ShellDispatcher.php(69): ShellDispatcher->dispatch()
#11 /Users/p_scott/cake221/app/Console/cake.php(33): ShellDispatcher::run(Array)
#12 {main}
一旦我開始收到此錯誤,我試圖在終端導航到<cake install dir>/app/Console
文件夾和文件夾<different instance of cake install dir>/app/Console
從我的應用程序/ s的範圍內儘量控制檯。我要麼得到同樣的錯誤,或者問我不同的問題,如:
What is the path to the project you want to bake?
[/Users/p_scott/myapp] > /Applications/MAMP/htdocs/history/app
What is the path to the directory layout you wish to copy?
[/Applications/MAMP/htdocs/history/lib/Cake/Console/Templates/skel] >
PHP CLI安裝,它似乎是工作
PHP 5.3.8 (cli) (built: Dec 5 2011 21:24:09)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
我PDO的支持似乎被啓用。在終端我鍵入:
php --ri pdo
PDO
PDO support => enabled
PDO drivers => mysql, sqlite, sqlite2
我沒有在Apache的一個php.ini文件(因爲我在Mac上),而是一個在PHP 5.36目錄下,我已經啓用了以下擴展名:
extension=imap.so
extension=yaz.so
extension=mcrypt.so
extension=gettext.so
extension=pgsql.so
extension=pdo_pgsql.so
extension=pdo_mysql.so
休息一會後,我發現,談論的變化的文章 (http://www.dereuromark.de/2011/10/31/freshly-baked-cake2-0-tips/)控制檯位置在2.0。我應該嘗試從該位置使用它(<cake installed dir>/lib/Cake/Console
)。一旦我嘗試了這個,我或者得到了關於我想要使用的佈局的問題,或者......一次,我能夠讓烘焙應用程序要求我創建數據庫配置。我經歷的步驟去了,它在最後筋疲力盡此錯誤:
Fatal error: Class 'DATABASE_CONFIG' not found in /Applications/MAMP/htdocs/history/lib/Cake/Console/Command/Task/DbConfigTask.php on line 264
這使我多了一個一塊信息。這是我在<cake installation dir>/history/app/Config/database.php
文件中的默認數據庫配置。
class DATABASE_CONFIG {
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'cakeHistoryUser',
'password' => 'cakeHistoryPassword',
'database' => 'cake_history',
'prefix' => '',
//'encoding' => 'utf8',
);
之前發佈了這個問題(和所有這些信息),我花了一些時間在這裏,它似乎像極了我的問題或CLI相關的,但我就是不明白,我需要改變幾小時和幾小時後,我需要一些幫助。
幫助我歐比旺,你是我唯一的希望
我試過了,它的工作馬上!謝謝!!我不敢相信這是一個簡單的解決方案。 – user1572358 2012-08-02 22:26:16
謝謝我被困住了,這有所幫助 – artSir 2013-11-21 20:22:52