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
db303447
Commit
db303447
authored
Mar 09, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update console.md
parent
26886b90
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
2 deletions
+20
-2
console.md
docs/guide/console.md
+20
-2
No files found.
docs/guide/console.md
View file @
db303447
...
@@ -136,5 +136,23 @@ class ExampleController extends \yii\console\Controller
...
@@ -136,5 +136,23 @@ class ExampleController extends \yii\console\Controller
### Exit Code
### Exit Code
Using return codes is the best practice of console application development. If command returns
`0`
it means everything
Using exit codes is the best practice of console application development. If a command returns
`0`
it means
is OK. If it is a number more than zero, we have an error and integer returned is the error code.
everything is OK. If it is a number greater than zero, we have an error and the number returned is the error
code that may be interpreted to find out details about the error.
For example
`1`
could stand generally for an unknown error and all codes above are declared for specific cases
such as input errors, missing files, and so forth.
To have your console command return with an exit code you simply return an integer in the controller action
method:
```
php
public
function
actionIndex
()
{
if
(
/* some problem */
)
{
echo
"A problem occured!
\n
"
;
return
1
;
}
// do something
return
0
;
}
```
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