php-yii
Run Yii framework console commands
TLDR
Start PHP's built-in web server for the current Yii application
Generate a controller, views and related files for the CRUD actions on the specified model class
Display help
SYNOPSIS
php-yii <command/action> [<arguments>...] [--<option>=<value>...]
PARAMETERS
--help or -h
Displays help information for the specified command or action.
--interactive=<0|1>
Controls whether the command runs in interactive mode, prompting for user confirmation (default depends on command, often 1).
--color=<0|1>
Enables or disables ANSI color output in the terminal (default is 1 if supported).
--appconfig=<path>
Specifies an alternative application configuration file for the console application.
--root-dir=<path>
Sets the root directory of the Yii application, useful when running from a different path.
DESCRIPTION
The `php-yii` command refers to the console application entry point of the Yii PHP framework. While not a standalone Linux binary itself, it typically represents an alias or direct execution of the `yii` (or `yii.php`) script using the PHP interpreter. This command provides a powerful command-line interface (CLI) for interacting with a Yii application. It's essential for various development, deployment, and maintenance tasks, including running database migrations, clearing caches, generating code via Gii, managing users, processing queues, and executing custom administrative scripts. It allows developers to automate repetitive tasks and manage application components outside of a web browser environment, leveraging the full capabilities of the Yii framework's architecture, including its dependency injection container and component system. Its flexibility makes it a cornerstone for managing complex Yii projects from the command line.
CAVEATS
php-yii is not a standard, pre-installed Linux command. It is a convention for invoking the Yii framework's console application script (`yii` or `yii.php`) using the PHP CLI interpreter.
It requires a functioning PHP CLI installation and must be executed within the context of a valid Yii framework project.
The available commands and their specific options are entirely dependent on the Yii application's structure, installed extensions, and custom console commands defined by the developer.
COMMON USAGE EXAMPLES
Illustrative examples of how php-yii is commonly used:
php-yii migrate/up - Applies pending database migrations to update the database schema.
php-yii cache/flush-all - Clears all application caches.
php-yii gii - Starts the Gii code generator, often leading to web-based generation or showing CLI options.
php-yii help - Lists all available console commands defined in the application.
php-yii help migrate/create - Displays detailed help for creating new database migration files.
COMMAND STRUCTURE
Yii console commands follow a controller-action pattern. A command like php-yii migrate/up typically executes the `actionUp()` method within the `MigrateController` (or `MigrateCommand` in Yii 1.x). Arguments are passed as method parameters, and options as named parameters, providing a clear and organized way to define and execute console tasks.
HISTORY
The Yii framework, created by Qiang Xue, was first publicly released in late 2008. From its inception, the console application component has been a fundamental feature, allowing developers to manage and automate various aspects of their web applications. This capability was consistently present throughout Yii 1.x and significantly enhanced in Yii 2.x, providing a robust, extensible system for command-line interactions. The invocation method, typically `php yii` or `./yii`, has remained consistent, establishing it as the primary interface for CLI-based application management within the Yii ecosystem.