0

我正在尝试在 Ubuntu 上运行 Cake Bake。要清楚:

  • 环境、文件系统、数据库和 DebugKit 都可以,正如 CakePhp 生成的第一页所提到的那样。
  • “bin/cake bake”显示此消息:
    PHP 警告:PHP 启动:无法加载动态库 '/usr/lib/php/20151012/php_intl.dll' - /usr/lib/php/20151012/php_intl.dll:无法打开共享对象文件:没有这样的文件或目录在第 0 行的未知中
    PHP 警告:PHP 启动:无法加载动态库 '/usr/lib/php/20151012/php_mbstring.dll' - /usr/lib/php/20151012/php_mbstring.dll:无法打开共享对象文件:没有这样的文件或目录在第 0 行的未知中

    欢迎使用 CakePHP v3.4.5 控制台
    -------------------------------------------------- -------------
    应用程序:src
    路径:/opt/lampp/htdocs/quizz/src/
    PHP : 7.0.18-1+deb.sury.org~xenial+1
    -------------------------------------------------- -------------
    以下命令可用于为您的应用程序生成框架代码。

    可用的烘焙命令:

    - 全部
    - 行为
    - 细胞
    - 零件
    - 控制器
    - 夹具
    - 形式
    - 帮手
    - 邮寄者
    - 移民
    - 迁移差异
    - 迁移快照
    - 模型
    - 插入
    - 种子
    - 壳
    - shell_helper
    - 任务
    - 模板
    - 测试

    通过使用`cake bake [name]`,您可以调用特定的烘焙任务。

  • 每次我运行“bin/cake bake model questions”或“bin/cake bake all”时,我都会得到以下输出:
PHP 警告:PHP 启动:无法加载动态库 '/usr/lib/php/20151012/php_intl.dll' - /usr/lib/php/20151012/php_intl.dll:无法打开共享对象文件:没有这样的文件或目录在第 0 行的未知中
PHP 警告:PHP 启动:无法加载动态库 '/usr/lib/php/20151012/php_mbstring.dll' - /usr/lib/php/20151012/php_mbstring.dll:无法打开共享对象文件:没有这样的文件或目录在第 0 行的未知中

欢迎使用 CakePHP v3.4.5 控制台
-------------------------------------------------- -------------
应用程序:src
路径:/opt/lampp/htdocs/quizz/src/
PHP : 7.0.18-1+deb.sury.org~xenial+1
-------------------------------------------------- -------------
检测到关联的某一时刻。
例外:SQLSTATE[HY000] [2002] [/opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Driver/PDODriverTrait.php,第 47 行] 中没有此类文件或目录
2017-05-07 14:24:47 错误:[PDOException] SQLSTATE[HY000] [2002] /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Driver/PDODriverTrait 中没有这样的文件或目录.php 在第 47 行
堆栈跟踪:
#0 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Driver/PDODriverTrait.php(47): PDO->__construct('mysql:host=loca...', 'root', '', 大批)
#1 /opt/lampp/htdocs/quizz/vendor/cakephp/cakephp/src/Database/Driver/Mysql.php(104): Cake\Database\Driver\Mysql->_connect('mysql:host=local... ', 大批)
#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), '答案','答案')
#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 {主要}
  • 当我提出“bin/cake bake controller questions”时,Cake Bake 运行。

经过几个小时的尝试解决问题后,我没有弄清楚问题出在哪里。我一直在窗户上使用蛋糕烘焙,但我从来没有发现运行蛋糕烘焙这么困难。我非常感谢您能提供的任何帮助。

4

2 回答 2

2

最后....只需将 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,
于 2017-05-07T19:32:04.150 回答
0

当我在 app.default.php 默认数据资源和 app.php 中更改 'host' => '127.0.0.1' 时,我的工作正常

我希望它会有所帮助

谢谢

于 2020-11-27T08:55:25.143 回答