Skip to content

Instantly share code, notes, and snippets.

@chuprik
Created May 2, 2016 08:02
Show Gist options
  • Save chuprik/38313e13fb2ab7be634fdbd1ea437eaa to your computer and use it in GitHub Desktop.
Save chuprik/38313e13fb2ab7be634fdbd1ea437eaa to your computer and use it in GitHub Desktop.
<?php
namespace app\commands;
use yii\console\Controller;
use yii\db\ColumnSchema;
class PhpDocController extends Controller
{
public function actionIndex()
{
$schema = \Yii::$app->db->getSchema();
$tables = $schema->getTableSchemas();
foreach ($tables as $tableSchema) {
echo "/**\n";
echo " * Table {$tableSchema->name}\n *\n";
foreach ($tableSchema->columns as $name => $data) {
/** @var ColumnSchema $data */
echo " * @property {$data->phpType} \${$name}\n";
}
echo " */\n\n";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment