Yii2 console commands

Hello, I have one big issue regarding console commands, so

I have easy console command stored in app/commands/TaskController.php




<?php

namespace app\commands;


use yii\console\Controller;

use app\models\FinishedTasks;


class TaskController extends Controller

{	

	

	public function actionDonwloadTasks(){

		$connection = \Yii::$app->db;

		print_R($connection);


		$zz = FinishedTasks::findOne(['id' => 3]);		

		print_r($zz);

	}

	

}



I execute it via console like:


D:\UwAmp\bin\php\php-5.5.15\php.exe yii task/donwload-tasks

And console response me this:


yii\db\Connection Object

(

    [dsn] => mysql:host=127.0.0.1;dbname=table_name

    [username] => root

    [password] => xxxxxxx

    [attributes] =>

    [pdo] =>

    [enableSchemaCache] =>

    [schemaCacheDuration] => 3600

    [schemaCacheExclude] => Array

        (

        )


    [schemaCache] => cache

    [enableQueryCache] => 1

    [queryCacheDuration] => 3600

    [queryCache] => cache

    [charset] => utf8

    [emulatePrepare] =>

    [tablePrefix] =>

    [schemaMap] => Array

        (

            [pgsql] => yii\db\pgsql\Schema

            [mysqli] => yii\db\mysql\Schema

            [mysql] => yii\db\mysql\Schema

            [sqlite] => yii\db\sqlite\Schema

            [sqlite2] => yii\db\sqlite\Schema

            [sqlsrv] => yii\db\mssql\Schema

            [oci] => yii\db\oci\Schema

            [mssql] => yii\db\mssql\Schema

            [dblib] => yii\db\mssql\Schema

            [cubrid] => yii\db\cubrid\Schema

        )


    [pdoClass] =>

    [enableSavepoint] => 1

    [serverStatusCache] => cache

    [serverRetryInterval] => 600

    [enableSlaves] => 1

    [slaves] => Array

        (

        )


    [slaveConfig] => Array

        (

        )


    [masters] => Array

        (

        )


    [masterConfig] => Array

        (

        )


    [_transaction:yii\db\Connection:private] =>

    [_schema:yii\db\Connection:private] =>

    [_driverName:yii\db\Connection:private] =>

    [_slave:yii\db\Connection:private] =>

    [_queryCacheInfo:yii\db\Connection:private] => Array

        (

        )


    [_events:yii\base\Component:private] => Array

        (

        )


    [_behaviors:yii\base\Component:private] =>

)

Exception 'yii\db\Exception' with message 'could not find driver'


in D:\trunk\app\vendor\yiisoft\yii2\db\Connection.php:534


Stack trace:

#0 D:\trunk\app\vendor\yiisoft\yii2\db\Connection.php(836): yii\db\Connection->open()

#1 D:\trunk\app\vendor\yiisoft\yii2\db\Connection.php(823): yii\db\Connection->getMasterPdo()

#2 D:\trunk\app\vendor\yiisoft\yii2\db\Command.php(206): yii\db\Connection->getSlavePdo()

#3 D:\trunk\app\vendor\yiisoft\yii2\db\Command.php(819): yii\db\Command->prepare(true)

#4 D:\trunk\app\vendor\yiisoft\yii2\db\Command.php(363): yii\db\Command->queryInternal('fetch', N

ULL)

#5 D:\trunk\app\vendor\yiisoft\yii2\db\Query.php(243): yii\db\Command->queryOne()

#6 D:\trunk\app\vendor\yiisoft\yii2\db\ActiveQuery.php(285): yii\db\Query->one(NULL)

#7 D:\trunk\app\vendor\yiisoft\yii2\db\BaseActiveRecord.php(101): yii\db\ActiveQuery->one()

#8 D:\trunk\app\commands\TaskController.php(22): yii\db\BaseActiveRecord::findOne(Array)

#9 [internal function]: app\commands\TaskController->actionDonwloadTasks()

#10 D:\trunk\app\vendor\yiisoft\yii2\base\InlineAction.php(55): call_user_func_array(Array, Array

)

#11 D:\trunk\app\vendor\yiisoft\yii2\base\Controller.php(151): yii\base\InlineAction->runWithPara

ms(Array)

#12 D:\trunk\app\vendor\yiisoft\yii2\console\Controller.php(91): yii\base\Controller->runAction('

donwload-tasks', Array)

#13 D:\trunk\app\vendor\yiisoft\yii2\base\Module.php(455): yii\console\Controller->runAction('don

wload-tasks', Array)

#14 D:\trunk\app\vendor\yiisoft\yii2\console\Application.php(161): yii\base\Module->runAction('ta

sk/donwload-t...', Array)

#15 D:\trunk\app\vendor\yiisoft\yii2\console\Application.php(137): yii\console\Application->runAc

tion('task/donwload-t...', Array)

#16 D:\trunk\app\vendor\yiisoft\yii2\base\Application.php(375): yii\console\Application->handleRe

quest(Object(yii\console\Request))

#17 D:\trunk\app\yii(23): yii\base\Application->run()

#18 {main}

I tried many ways already, but still have "could not find driver" error! Maybe someone know how to fix it?

I use UwAmp 3.0.2, Windows 8.1. Maybe this will work on linux server?

but all other website, if its not started via console works fine, no errors received, db requests works properly

Hello,

The Yii console uses the PHP client that loads its configuration from the "PHP.INI" file. This file does not exist in the PHP directory.

Make all your PHP configuration in the GUI, then go the the PHP-xxxx directory and copy "php_uwamp.ini" file to "php.ini".

Edit the "php.ini" file and search the "extension_dir" variable.

Replace the line : extension_dir = "{PHPEXTPATH}"

With : extension_dir = "./ext"

For me it solves the same problem I had.