Skip to content

Commit 915bc5a

Browse files
committed
2 parents d29b5e1 + ddd313d commit 915bc5a

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

yii2/assets/dump.png

555 KB
Loading

yii2/assets/help.png

720 KB
Loading

yii2/yii-shell.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Yii2 Shell
2+
3+
The Yii shell provides a [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) for the application.
4+
This can be useful in experimenting with code or evaluating behavior from within the application.
5+
6+
This is provided by the YiiSoft [yii2-shell](https://github.com/yiisoft/yii2-shell) project.
7+
8+
## Usage
9+
10+
The shell is available via the Yii CLI with `console/yii shell`. This will provide a prompt that evaluates PHP code in the context of a
11+
fully bootstrapped application.
12+
In common usage, it is likely preferable to access this via one of the Docker containers like `docker exec -it sourcetoad_core_php console/yii shell`.
13+
This allows for Docker based routing to the database container and the Station/Satellite pair.
14+
15+
## Features
16+
17+
### Shell Specific Commands
18+
19+
The shell makes available a number of specific commands.
20+
![help](./assets/help.png)
21+
22+
`dump` provides a well organized and readable dump.
23+
![dump](./assets/dump.png)
24+
25+
An input history is kept locally and can be navigated via the arrow keys, similar to bash.
26+
27+
## Caveats
28+
29+
While classes are autoloaded they must be referenced via full namespaces. If working in a particular namespace this can
30+
be assigned.
31+
32+
`$asset = new common\modules\media\models\Asset()`
33+
34+
versus
35+
36+
```php
37+
namespace common\modules\media;
38+
$asset = new models\Asset();
39+
```

0 commit comments

Comments
 (0)