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
056d8ccc
Commit
056d8ccc
authored
Oct 19, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[skip ci] Added formatting and colors section to console guide
parent
019d0ad6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
tutorial-console.md
docs/guide/tutorial-console.md
+20
-0
No files found.
docs/guide/tutorial-console.md
View file @
056d8ccc
...
...
@@ -163,3 +163,23 @@ There are some predefined constants you can use:
-
`Controller::EXIT_CODE_NORMAL`
with value of
`0`
;
-
`Controller::EXIT_CODE_ERROR`
with value of
`1`
.
It's a good practice to define meaningful constants for your controller in case you have more error code types.
### Formatting and colors
Yii console supports formatted output that is automatically degraded to non-formatted one if it's not supported
by terminal running the command.
Outputting formatted strings is simple. Here's how to output some bold text:
```
php
$this
->
stdout
(
"Hello?
\n
"
,
Console
::
BOLD
);
```
If you need to build string dynamically combining multiple styles it's better to use
`ansiFormat`
:
```
php
$name
=
$this
->
ansiFormat
(
'Alex'
,
Console
::
FG_YELLOW
);
echo
"Hello, my name is
$name
."
;
```
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