Linux command
php-yii 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
List available commands
php yii help
Run database migrations
php yii migrate
Create a new migration
php yii migrate/create [create_users_table]
Rollback last migration
php yii migrate/down
Generate model from table
php yii gii/model --tableName=[table] --modelClass=[ModelName]
Generate CRUD
php yii gii/crud --modelClass=[app\\models\\Post]
Clear all caches
php yii cache/flush-all
Get help for a specific command
php yii help [migrate]
说明
yii is the console entry point for Yii 2.0 PHP framework applications. It provides access to built-in commands for database migrations, code generation, caching, asset management, and application serving. Console commands use the route format controller/action (e.g., migrate/create). Options are passed as --option=value. Custom console commands can be created by extending yii\console\Controller. The gii commands provide code generation capabilities for models, controllers, CRUD interfaces, forms, modules, and extensions. The migrate commands manage database schema changes through versioned migration files.
参数
- --tableName _name_
- Database table name (gii/model).
- --modelClass _class_
- Model class name (gii/model, gii/crud).
- --interactive _0|1_
- Run in non-interactive mode. Default: 1.
- --color _0|1_
- Enable/disable ANSI color output.
FAQ
What is the php-yii command used for?
yii is the console entry point for Yii 2.0 PHP framework applications. It provides access to built-in commands for database migrations, code generation, caching, asset management, and application serving. Console commands use the route format controller/action (e.g., migrate/create). Options are passed as --option=value. Custom console commands can be created by extending yii\console\Controller. The gii commands provide code generation capabilities for models, controllers, CRUD interfaces, forms, modules, and extensions. The migrate commands manage database schema changes through versioned migration files.
How do I run a basic php-yii example?
Run `php yii help` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --tableName _name_ do in php-yii?
Database table name (gii/model).