Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
f22c5212
Commit
f22c5212
authored
Nov 29, 2013
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A bit more docs on console applications
parent
951da01c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
3 deletions
+47
-3
console.md
docs/guide/console.md
+47
-3
No files found.
docs/guide/console.md
View file @
f22c5212
...
...
@@ -7,7 +7,7 @@ consists of one or more [[\yii\console\Controller]] (often referred to as comman
Usage
-----
User executes
controller action using the following syntax:
You can execute
controller action using the following syntax:
```
yii <route> [--param1=value1 --param2 ...]
...
...
@@ -20,13 +20,54 @@ line like the following:
yii migreate/create --migrationTable=my_migration
```
In the above
`yii`
is console application entry script described below.
Entry script
------------
Console application entry script is typically called
`yii`
, located in your application root directory and contains
code like the following:
```
php
#!/usr/bin/env php
<?php
/**
* Yii console bootstrap file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
defined
(
'YII_DEBUG'
)
or
define
(
'YII_DEBUG'
,
true
);
// fcgi doesn't have STDIN defined by default
defined
(
'STDIN'
)
or
define
(
'STDIN'
,
fopen
(
'php://stdin'
,
'r'
));
require
(
__DIR__
.
'/vendor/autoload.php'
);
require
(
__DIR__
.
'/vendor/yiisoft/yii2/yii/Yii.php'
);
$config
=
require
(
__DIR__
.
'/config/console.php'
);
$application
=
new
yii\console\Application
(
$config
);
$exitCode
=
$application
->
run
();
exit
(
$exitCode
);
```
This script is a part of your application so you're free to adjust it. There
`YII_DEBUG`
can be turned off if you do
not want to see stacktrace on error and want to improve overall performance. In both basic and advanced application
templates it is enabled to provide more developer-friendly environment.
Configuration
-------------
As can be seen in the code above, console application uses its own config files named
`console.php`
so you need to
configure database connection and the rest of the components you're going to use there in that file. If web and console
application configs have a lot in common it's a good idea to move matching parts into their own config files as it was
done in advanced application template.
Creating your own console commands
----------------------------------
...
...
@@ -36,4 +77,7 @@ Creating your own console commands
### Parameters
### Return codes
\ No newline at end of file
### Return codes
Using return codes is the best practice of console application development. If command returns
`0`
it means everything
is OK. If it is a number more than zero, we have an error and integer returned is the error code.
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment