Hi All,
I am brand new to the Yii2 Framework and have spent some time reading through the 2.0 getting started documentation having fun with the basic template. All working great and have been able to manually create a PostgresDb as part of the exercises and also access this via the Gii tools.
I stumbled across the improved basic template over the weekend and wanted to try it out locally. However I’m having real trouble trying to run the ‘./yii migrate’ command from the console and keep getting the following error:
Exception 'yii\db\Exception' with message 'could not find driver'
in /Applications/MAMP/htdocs/advanced/_protected/vendor/yiisoft/yii2/db/Connection.php:534
Stack trace:
#0 /Applications/MAMP/htdocs/advanced/_protected/vendor/yiisoft/yii2/db/Connection.php(836): yii\db\Connection->open()
#1 /Applications/MAMP/htdocs/advanced/_protected/vendor/yiisoft/yii2/db/Connection.php(823): yii\db\Connection->getMasterPdo()
#2 /Applications/MAMP/htdocs/advanced/_protected/vendor/yiisoft/yii2/db/Schema.php(382): yii\db\Connection->getSlavePdo()
#3 /Applications/MAMP/htdocs/advanced/_protected/vendor/yiisoft/yii2/db/Connection.php(732): yii\db\Schema->quoteValue('migration')
#4 /Applications/MAMP/htdocs/advanced/_protected/vendor/yiisoft/yii2/db/pgsql/Schema.php(319): yii\db\Connection->quoteValue('migration')
#5 /Applications/MAMP/htdocs/advanced/_protected/vendor/yiisoft/yii2/db/pgsql/Schema.php(160): yii\db\pgsql\Schema->findColumns(Object(yii\db\TableSchema))
#6 /Applications/MAMP/htdocs/advanced/_protected/vendor/yiisoft/yii2/db/Schema.php(139): yii\db\pgsql\Schema->loadTableSchema('migration')
#7 /Applications/MAMP/htdocs/advanced/_protected/vendor/yiisoft/yii2/console/controllers/MigrateController.php(125): yii\db\Schema->getTableSchema('{{%migration}}', true)
#8 /Applications/MAMP/htdocs/advanced/_protected/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(604): yii\console\controllers\MigrateController->getMigrationHistory(NULL)
#9 /Applications/MAMP/htdocs/advanced/_protected/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(99): yii\console\controllers\BaseMigrateController->getNewMigrations()
#10 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
#11 /Applications/MAMP/htdocs/advanced/_protected/vendor/yiisoft/yii2/base/InlineAction.php(55): call_user_func_array(Array, Array)
#12 /Applications/MAMP/htdocs/advanced/_protected/vendor/yiisoft/yii2/base/Controller.php(151): yii\base\InlineAction->runWithParams(Array)
#13 /Applications/MAMP/htdocs/advanced/_protected/vendor/yiisoft/yii2/console/Controller.php(91): yii\base\Controller->runAction('', Array)
#14 /Applications/MAMP/htdocs/advanced/_protected/vendor/yiisoft/yii2/base/Module.php(455): yii\console\Controller->runAction('', Array)
#15 /Applications/MAMP/htdocs/advanced/_protected/vendor/yiisoft/yii2/console/Application.php(161): yii\base\Module->runAction('migrate', Array)
#16 /Applications/MAMP/htdocs/advanced/_protected/vendor/yiisoft/yii2/console/Application.php(137): yii\console\Application->runAction('migrate', Array)
#17 /Applications/MAMP/htdocs/advanced/_protected/vendor/yiisoft/yii2/base/Application.php(375): yii\console\Application->handleRequest(Object(yii\console\Request))
#18 /Applications/MAMP/htdocs/advanced/_protected/yii(23): yii\base\Application->run()
#19 {main}
I have since installed MYSQL and the Sequel Pro tool on my mac. I have create a db called ‘robone’ and my ‘_protected/config/db.php’ looks as follows:
<?php
return [
'class' => 'yii\db\Connection',
'dsn' => 'pgsql:host=localhost;dbname=robone',
'username' => 'root',
'password' => 'XXXXXXX',
'charset' => 'utf8',
];
I am running using MAMP which all seems to work fine for the original basic template. I’ve al so run phpinfo() to check that I have mysql pdo installed and all looks fine there.
Really getting stuck with this now and I’m sure it’s probably something really simple I’m missing is anyone able to offer some hugely appreciated sage advice?
Thanks