CakePhp:蛋糕烘焙在 Ubuntu 上不起作用。 (PDO异常)
CakePhp : Cake bake doesn't work on Ubuntu. (PDOException)
我正在尝试 运行 在 Ubuntu 上烤蛋糕。
要清楚:
- 环境、文件系统、数据库和 DebugKit 正常,正如 CakePhp 生成的第一页中提到的那样。
- "bin/cake bake" 显示此消息:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_intl.dll' - /usr/lib/php/20151012/php_intl.dll: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_mbstring.dll' - /usr/lib/php/20151012/php_mbstring.dll: cannot open shared object file: No such file or directory in Unknown on line 0
Welcome to CakePHP v3.4.5 Console
---------------------------------------------------------------
App : src
Path: /opt/lampp/htdocs/quizz/src/
PHP : 7.0.18-1+deb.sury.org~xenial+1
---------------------------------------------------------------
The following commands can be used to generate skeleton code for your application.
Available bake commands:
- all
- behavior
- cell
- component
- controller
- fixture
- form
- helper
- mailer
- migration
- migration_diff
- migration_snapshot
- model
- plugin
- seed
- shell
- shell_helper
- task
- template
- test
By using `cake bake [name]` you can invoke a specific bake task.
- 每次我 运行 'bin/cake bake model questions' 或 'bin/cake bake all' 我得到这个输出:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_intl.dll' - /usr/lib/php/20151012/php_intl.dll: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_mbstring.dll' - /usr/lib/php/20151012/php_mbstring.dll: cannot open shared object file: No such file or directory in Unknown on line 0
Welcome to CakePHP v3.4.5 Console
---------------------------------------------------------------
App : src
Path: /opt/lampp/htdocs/quizz/src/
PHP : 7.0.18-1+deb.sury.org~xenial+1
---------------------------------------------------------------
One moment while associations are detected.
Exception: SQLSTATE[HY000] [2002] No such file or directory in [/opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Driver/PDODriverTrait.php, line 47]
2017-05-07 14:24:47 Error: [PDOException] SQLSTATE[HY000] [2002] No such file or directory in /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Driver/PDODriverTrait.php on line 47
Stack Trace:
#0 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Driver/PDODriverTrait.php(47): PDO->__construct('mysql:host=loca...', 'root', '', Array)
#1 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Driver/Mysql.php(104): Cake\Database\Driver\Mysql->_connect('mysql:host=loca...', Array)
#2 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Schema/BaseSchema.php(45): Cake\Database\Driver\Mysql->connect()
#3 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Dialect/MysqlDialectTrait.php(63): Cake\Database\Schema\BaseSchema->__construct(Object(Cake\Database\Driver\Mysql))
#4 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Schema/Collection.php(52): Cake\Database\Driver\Mysql->schemaDialect()
#5 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Schema/CachedCollection.php(42): Cake\Database\Schema\Collection->__construct(Object(Cake\Database\Connection))
#6 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Connection.php(367): Cake\Database\Schema\CachedCollection->__construct(Object(Cake\Database\Connection), true)
#7 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Connection.php(386): Cake\Database\Connection->getSchemaCollection()
#8 /opt/lampp/htdocs/quizz/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(959): Cake\Database\Connection->schemaCollection()
#9 /opt/lampp/htdocs/quizz/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(911): Bake\Shell\Task\ModelTask->_getAllTables()
#10 /opt/lampp/htdocs/quizz/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(207): Bake\Shell\Task\ModelTask->listAll()
#11 /opt/lampp/htdocs/quizz/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(127): Bake\Shell\Task\ModelTask->getAssociations(Object(Cake\ORM\Table))
#12 /opt/lampp/htdocs/quizz/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(110): Bake\Shell\Task\ModelTask->getTableContext(Object(Cake\ORM\Table), 'answers', 'Answers')
#13 /opt/lampp/htdocs/quizz/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(97): Bake\Shell\Task\ModelTask->bake('Answers')
#14 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Console/Shell.php(472): Bake\Shell\Task\ModelTask->main('answers')
#15 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Console/Shell.php(465): Cake\Console\Shell->runCommand(Array, false, Array)
#16 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(230): Cake\Console\Shell->runCommand(Array, true, Array)
#17 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(182): Cake\Console\ShellDispatcher->_dispatch(Array)
#18 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(128): Cake\Console\ShellDispatcher->dispatch(Array)
#19 /opt/lampp/htdocs/quizz/bin/cake.php(34): Cake\Console\ShellDispatcher::run(Array)
#20 {main}
- 蛋糕烘烤 运行 当我放 'bin/cake bake controller questions'.
我花了几个小时试图解决它后,没有弄清楚问题是什么。我一直在 windows 上使用蛋糕烘焙,但我从未发现 运行 蛋糕烘焙有如此困难。
非常感谢您提供的任何帮助。
终于……
只需将 localhost 替换为 127.0.0.1
'Datasources' => [
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'localhost',
/**
* CakePHP will use the default DB port based on the driver selected
* MySQL on MAMP uses port 8889, MAMP users will want to uncomment
* the following line and set the port accordingly
*/
//'port' => 'non_standard_port_number',
'username' => 'root',
'password' => '',
'database' => 'quizz_db',
'encoding' => 'utf8',
'timezone' => 'UTC',
'flags' => [],
'cacheMetadata' => true,
'log' => false,
作者:
'Datasources' => [
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => '127.0.0.1',
/**
* CakePHP will use the default DB port based on the driver selected
* MySQL on MAMP uses port 8889, MAMP users will want to uncomment
* the following line and set the port accordingly
*/
//'port' => 'non_standard_port_number',
'username' => 'root',
'password' => '',
'database' => 'quizz_db',
'encoding' => 'utf8',
'timezone' => 'UTC',
'flags' => [],
'cacheMetadata' => true,
'log' => false,
当我改变时我的工作正常
'host' => '127.0.0.1',在 app.default.php 默认数据资源中
在 app.php
希望对您有所帮助
谢谢
我正在尝试 运行 在 Ubuntu 上烤蛋糕。 要清楚:
- 环境、文件系统、数据库和 DebugKit 正常,正如 CakePhp 生成的第一页中提到的那样。
- "bin/cake bake" 显示此消息:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_intl.dll' - /usr/lib/php/20151012/php_intl.dll: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_mbstring.dll' - /usr/lib/php/20151012/php_mbstring.dll: cannot open shared object file: No such file or directory in Unknown on line 0 Welcome to CakePHP v3.4.5 Console --------------------------------------------------------------- App : src Path: /opt/lampp/htdocs/quizz/src/ PHP : 7.0.18-1+deb.sury.org~xenial+1 --------------------------------------------------------------- The following commands can be used to generate skeleton code for your application. Available bake commands: - all - behavior - cell - component - controller - fixture - form - helper - mailer - migration - migration_diff - migration_snapshot - model - plugin - seed - shell - shell_helper - task - template - test By using `cake bake [name]` you can invoke a specific bake task.
- 每次我 运行 'bin/cake bake model questions' 或 'bin/cake bake all' 我得到这个输出:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_intl.dll' - /usr/lib/php/20151012/php_intl.dll: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_mbstring.dll' - /usr/lib/php/20151012/php_mbstring.dll: cannot open shared object file: No such file or directory in Unknown on line 0 Welcome to CakePHP v3.4.5 Console --------------------------------------------------------------- App : src Path: /opt/lampp/htdocs/quizz/src/ PHP : 7.0.18-1+deb.sury.org~xenial+1 --------------------------------------------------------------- One moment while associations are detected. Exception: SQLSTATE[HY000] [2002] No such file or directory in [/opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Driver/PDODriverTrait.php, line 47] 2017-05-07 14:24:47 Error: [PDOException] SQLSTATE[HY000] [2002] No such file or directory in /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Driver/PDODriverTrait.php on line 47 Stack Trace: #0 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Driver/PDODriverTrait.php(47): PDO->__construct('mysql:host=loca...', 'root', '', Array) #1 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Driver/Mysql.php(104): Cake\Database\Driver\Mysql->_connect('mysql:host=loca...', Array) #2 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Schema/BaseSchema.php(45): Cake\Database\Driver\Mysql->connect() #3 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Dialect/MysqlDialectTrait.php(63): Cake\Database\Schema\BaseSchema->__construct(Object(Cake\Database\Driver\Mysql)) #4 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Schema/Collection.php(52): Cake\Database\Driver\Mysql->schemaDialect() #5 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Schema/CachedCollection.php(42): Cake\Database\Schema\Collection->__construct(Object(Cake\Database\Connection)) #6 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Connection.php(367): Cake\Database\Schema\CachedCollection->__construct(Object(Cake\Database\Connection), true) #7 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Connection.php(386): Cake\Database\Connection->getSchemaCollection() #8 /opt/lampp/htdocs/quizz/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(959): Cake\Database\Connection->schemaCollection() #9 /opt/lampp/htdocs/quizz/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(911): Bake\Shell\Task\ModelTask->_getAllTables() #10 /opt/lampp/htdocs/quizz/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(207): Bake\Shell\Task\ModelTask->listAll() #11 /opt/lampp/htdocs/quizz/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(127): Bake\Shell\Task\ModelTask->getAssociations(Object(Cake\ORM\Table)) #12 /opt/lampp/htdocs/quizz/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(110): Bake\Shell\Task\ModelTask->getTableContext(Object(Cake\ORM\Table), 'answers', 'Answers') #13 /opt/lampp/htdocs/quizz/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(97): Bake\Shell\Task\ModelTask->bake('Answers') #14 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Console/Shell.php(472): Bake\Shell\Task\ModelTask->main('answers') #15 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Console/Shell.php(465): Cake\Console\Shell->runCommand(Array, false, Array) #16 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(230): Cake\Console\Shell->runCommand(Array, true, Array) #17 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(182): Cake\Console\ShellDispatcher->_dispatch(Array) #18 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(128): Cake\Console\ShellDispatcher->dispatch(Array) #19 /opt/lampp/htdocs/quizz/bin/cake.php(34): Cake\Console\ShellDispatcher::run(Array) #20 {main}
- 蛋糕烘烤 运行 当我放 'bin/cake bake controller questions'.
我花了几个小时试图解决它后,没有弄清楚问题是什么。我一直在 windows 上使用蛋糕烘焙,但我从未发现 运行 蛋糕烘焙有如此困难。 非常感谢您提供的任何帮助。
终于…… 只需将 localhost 替换为 127.0.0.1
'Datasources' => [
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'localhost',
/**
* CakePHP will use the default DB port based on the driver selected
* MySQL on MAMP uses port 8889, MAMP users will want to uncomment
* the following line and set the port accordingly
*/
//'port' => 'non_standard_port_number',
'username' => 'root',
'password' => '',
'database' => 'quizz_db',
'encoding' => 'utf8',
'timezone' => 'UTC',
'flags' => [],
'cacheMetadata' => true,
'log' => false,
作者:
'Datasources' => [
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => '127.0.0.1',
/**
* CakePHP will use the default DB port based on the driver selected
* MySQL on MAMP uses port 8889, MAMP users will want to uncomment
* the following line and set the port accordingly
*/
//'port' => 'non_standard_port_number',
'username' => 'root',
'password' => '',
'database' => 'quizz_db',
'encoding' => 'utf8',
'timezone' => 'UTC',
'flags' => [],
'cacheMetadata' => true,
'log' => false,
当我改变时我的工作正常 'host' => '127.0.0.1',在 app.default.php 默认数据资源中 在 app.php
希望对您有所帮助
谢谢