Answer the question
In order to leave comments, you need to log in
How to fix a migration error?
I want to activate migration in yii2. Before that I created a migration:
class m160529_212620_user extends Migration
{
public function up(){
$this->createTable('user',[
'id' => $this->primaryKey(),
'name' => $this->string()->notNull(),
'last_name' => $this->string(),
] );
}
public function down()
{
echo "m160529_212620_user cannot be reverted.\n";
return false;
}
./yii migratе
but it throws the following error:
PHP Fatal Error 'yii\base\ErrorException' with message 'Class 'PDO' not found'
in /home/vitaliy/hosts/myuseyii.dev/vendor/yiisoft/yii2/db/Connection.php:631
Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleFatalError()
#1 {main}
extension=pdo.dll
extension=php_pdo_mysql.dll
Answer the question
In order to leave comments, you need to log in
Apache and the console seem to use different php.ini files.
Look for another config.
php -i | grep Configuration
to solve this problem, you need to specify where the php.ini configuration file is located
php -c [path]/php.ini yii migrate [email protected]/rbac/migrations if it does not work, then
you
have not specified the path to php.ini correctly
naturally in php.ini itself there should be lines:
...
extension=pdo.so
extension=pdo_mysql.so
...
my working command in the console looked like this:
php -c ../../php.ini yii migrate -- [email protected]/rbac/migrations
I specified the path relative to the place where I was ... that is, I went up two levels.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question