Add column to a table dynamically

Hi, does anyone know how to create a button to add a column in the db table in yii2?

I found this but I haven’t tried it in yii2

Yii::app()->db->schema->addColumn( 'table_name', 'column_name', 'column type default xxx' );
Yii::app()->db->schema->dropColumn( 'tables_name', 'column_name' );

I found this

This should work!

$this->addColumn('table_name', 'column_name', 'type AFTER column6'); 

examples:

$this->addColumn('tbl_posts', 'email', 'VARCHAR(150) AFTER `name` ');
$this->addColumn('tbl_posts', 'phone', 'string AFTER `email` ');

but browser shows me this

Calling unknown method: app\controllers\EjemploController::addColumn()