找不到驱动程序Yii2迁移

时间:2018-05-23 00:48:14

标签: php database yii2 xampp migration

我是Yii2的新手,所以我在迁移到XAMPP服务器时遇到问题。我的PHP版本是7.1.11。我正在使用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,
        ],
    ],
];

错误:

 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}

运行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]

知道怎么解决这个问题吗?我尝试过以前问过的所有类似解决方案。

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

1 个答案:

答案 0 :(得分:2)

正如您在official guide上所看到的,您需要安装 pdo ,在您的情况下, pdo_mysql 。你错过了最后一个。