简体   繁体   English

找不到驱动 Yii2 迁移

[英]Could not find driver Yii2 migration

I am new to Yii2 so I have a problem migrating to XAMPP server.我是 Yii2 的新手,所以我在迁移到 XAMPP 服务器时遇到了问题。 My PHP version is 7.1.11 .我的 PHP 版本是 7.1.11 。 I am using Yii2 advanced template, and this is how my common/config/main-local.php file looks like我正在使用 Yii2 高级模板,这就是我的common/config/main-local.php文件的样子

<?php
return [
    'components' => [
        'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=127.0.0.1;dbname=hopordrop',
            'username' => 'root',
            'password' => '',
            'charset' => 'utf8',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'viewPath' => '@common/mail',
            // send all mails to a file by default. You have to set
            // 'useFileTransport' to false and configure a transport
            // for the mailer to send real emails.
            'useFileTransport' => true,
        ],
    ],
];

Error:错误:

 Stack trace:
    #0 C:\xampp\htdocs\hoppordropp\vendor\yiisoft\yii2\db\Connection.php(864): yii\db\Connection->open()
    #1 C:\xampp\htdocs\hoppordropp\vendor\yiisoft\yii2\db\Connection.php(851): yii\db\Connection->getMasterPdo()
    #2 C:\xampp\htdocs\hoppordropp\vendor\yiisoft\yii2\db\Command.php(219): yii\db\Connection->getSlavePdo()
    #3 C:\xampp\htdocs\hoppordropp\vendor\yiisoft\yii2\db\Command.php(894): yii\db\Command->prepare(true)
    #4 C:\xampp\htdocs\hoppordropp\vendor\yiisoft\yii2\db\Command.php(362): yii\db\Command->queryInternal('fetchAll', NULL)
    #5 C:\xampp\htdocs\hoppordropp\vendor\yiisoft\yii2\db\mysql\Schema.php(198): yii\db\Command->queryAll()
    #6 C:\xampp\htdocs\hoppordropp\vendor\yiisoft\yii2\db\mysql\Schema.php(97): yii\db\mysql\Schema->findColumns(Object(yii\db\TableSchema))
    #7 C:\xampp\htdocs\hoppordropp\vendor\yiisoft\yii2\db\Schema.php(149): yii\db\mysql\Schema->loadTableSchema('migration')#8 C:\xampp\htdocs\hoppordropp\vendor\yiisoft\yii2\console\controllers\MigrateController.php(178): yii\db\Schema->getTableSchema('{{%migration}}', true)
    #9 C:\xampp\htdocs\hoppordropp\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(627): yii\console\controllers\MigrateController->getMigrationHistory(NULL)
    #10 C:\xampp\htdocs\hoppordropp\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(102): yii\console\controllers\BaseMigrateController->getNewMigrations()
    #11 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
    #12 C:\xampp\htdocs\hoppordropp\vendor\yiisoft\yii2\base\InlineAction.php(55): call_user_func_array(Array, Array)
    #13 C:\xampp\htdocs\hoppordropp\vendor\yiisoft\yii2\base\Controller.php(154): yii\base\InlineAction->runWithParams(Array)
    #14 C:\xampp\htdocs\hoppordropp\vendor\yiisoft\yii2\console\Controller.php(119): yii\base\Controller->runAction('', Array)
    #15 C:\xampp\htdocs\hoppordropp\vendor\yiisoft\yii2\base\Module.php(454): yii\console\Controller->runAction('', Array)
    #16 C:\xampp\htdocs\hoppordropp\vendor\yiisoft\yii2\console\Application.php(180): yii\base\Module->runAction('migrate', Array)
    #17 C:\xampp\htdocs\hoppordropp\vendor\yiisoft\yii2\console\Application.php(147): yii\console\Application->runAction('migrate', Array)
    #18 C:\xampp\htdocs\hoppordropp\vendor\yiisoft\yii2\base\Application.php(375): yii\console\Application->handleRequest(Object(yii\console\Request))
    #19 C:\xampp\htdocs\hoppordropp\yii(27): yii\base\Application->run()
    #20 {main}

When run php -m command:运行php -m命令时:

[PHP Modules]
bcmath
calendar
Core
ctype
date
dom
filter
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
Phar
readline
Reflection
session
SimpleXML
SPL
standard
tokenizer
wddx
xml
xmlreader
xmlwriter
zip
zlib

[Zend Modules]

Any idea how to fix this?知道如何解决这个问题吗? I have tried all similar solutions from previously asked questions.我已经尝试了以前提出的问题的所有类似解决方案。

Name    Result  Required By Memo
PHP version Passed  Yii Framework   PHP 5.4.0 or higher is required.
Reflection extension    Passed  Yii Framework   
PCRE extension  Passed  Yii Framework   
SPL extension   Passed  Yii Framework   
Ctype extension Passed  Yii Framework   
MBString extension  Passed  Multibyte string processing Required for multibyte encoding string processing.
OpenSSL extension   Passed  Security Component  Required by encrypt and decrypt methods.
Intl extension  Passed  Internationalization support    PHP Intl extension 1.0.2 or higher is required when you want to use advanced parameters formatting in Yii::t(), non-latin languages with Inflector::slug(), IDN-feature of EmailValidator or UrlValidator or the yii\i18n\Formatter class.
ICU version Passed  Internationalization support    ICU 49.0 or higher is required when you want to use # placeholder in plural rules (for example, plural in Formatter::asRelativeTime()) in the yii\i18n\Formatter class. Your current ICU version is 57.1.
ICU Data version    Passed  Internationalization support    ICU Data 49.1 or higher is required when you want to use # placeholder in plural rules (for example, plural in Formatter::asRelativeTime()) in the yii\i18n\Formatter class. Your current ICU Data version is 57.1.
Fileinfo extension  Passed  File Information    Required for files upload to detect correct file mime-types.
DOM extension   Passed  Document Object Model   Required for REST API to send XML responses via yii\web\XmlResponseFormatter.
PDO extension   Passed  All DB-related classes  
PDO SQLite extension    Passed  All DB-related classes  Required for SQLite database.
PDO MySQL extension Passed  All DB-related classes  Required for MySQL database.
PDO PostgreSQL extension    Passed  All DB-related classes  Required for PostgreSQL database.
Memcache extension  Warning MemCache    
APC extension   Warning ApcCache    
GD PHP extension with FreeType support  Passed  Captcha Either GD PHP extension with FreeType support or ImageMagick PHP extension with PNG support is required for image CAPTCHA.
ImageMagick PHP extension with PNG support  Warning Captcha Either GD PHP extension with FreeType support or ImageMagick PHP extension with PNG support is required for image CAPTCHA.
Expose PHP  Warning Security reasons    "expose_php" should be disabled at php.ini
PHP allow url include   Passed  Security reasons    "allow_url_include" should be disabled at php.ini
PHP mail SMTP   Passed  Email sending   PHP mail SMTP server required

As you can read on the official guide , You need to install pdo and in your case, pdo_mysql .正如您在官方指南中所读到的,您需要安装pdo ,在您的情况下,安装pdo_mysql You're missing the last one.你错过了最后一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM