Yii::createConsoleApplication([ 'basePath' => __DIR__, 'components' => [ 'db' => [ 'class' => 'yii\db\Connection', 'dsn' => 'mysql:host=localhost;dbname=my_db', 'username' => 'root', 'password' => '', 'charset' => 'utf8' ] ] ]);
Yii::createConsoleApplication([ 'id' => 'my-console-app', 'basePath' => __DIR__, 'components' => [ 'email' => [ 'class' => 'yii\swiftmailer\Mailer', 'viewPath' => '@app/mail', 'useFileTransport' => true, ], ], 'controllerMap' => [ 'email' => 'app\commands\EmailController', ], ]);This example sets up a console application with an email component and a `EmailController` defined in the `app\commands` namespace that can send emails from the command line. Package/Library: Yii Framework, SwiftMailer In summary, createConsoleApplication is a method provided by the Yii Framework that enables the creation of console applications in PHP, which can be used to accomplish tasks like database migrations, cron jobs, sending emails, and many others. The examples provided demonstrate how to set up a console application with a database and email component, and how to define a controller that can send emails from the command line. The package/library used in these examples is the Yii Framework, in addition to the SwiftMailer library used for email functionality.