Skip to content

Commit 076c974

Browse files
authored
Merge pull request #100 from HOSTED-POWER/BjarneVO-Magento2
Cleaned up magento2cli.md and added descriptions for commands.
2 parents cbde937 + fbdb540 commit 076c974

1 file changed

Lines changed: 100 additions & 95 deletions

File tree

Technologies/CMS & Frameworks/Magento 2/magento2cli.md

Lines changed: 100 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -3,187 +3,192 @@ hidden: true
33
---
44
# Magento 2 CLI
55

6-
Magento 2 provides a powerful command-line interface (CLI) tool to manage and configure your store efficiently. Below is a categorized overview of all major `php bin/magento` commands.
6+
Magento 2 provides a powerful command-line interface (CLI) tool to manage and configure your store efficiently. Below is a categorized overview of all major `php bin/magento` commands, with explanations where needed.
77

88
---
99

1010
## Setup & Installation
1111

1212
### Install & Upgrade
13-
```bash
14-
php bin/magento setup:install
15-
php bin/magento setup:upgrade
16-
php bin/magento setup:di:compile
17-
php bin/magento setup:static-content:deploy
18-
php bin/magento setup:static-content:deploy -f
19-
php bin/magento setup:uninstall
20-
```
13+
14+
| Command | Description |
15+
|--------|-------------|
16+
| `setup:install` | Installs Magento with DB and admin configuration. |
17+
| `setup:upgrade` | Applies DB schema/data changes from modules. |
18+
| `setup:di:compile` | Compiles dependency injection code. |
19+
| `setup:static-content:deploy` | Deploys static view files for frontend. |
20+
| `setup:static-content:deploy -f` | Forces deployment even in developer mode. |
21+
| `setup:uninstall` | Uninstalls Magento and removes configuration. |
2122

2223
### Config Status & Maintenance
23-
```bash
24-
php bin/magento setup:config:set
25-
php bin/magento setup:db:status
26-
php bin/magento setup:db:status --show-config
27-
php bin/magento maintenance:enable
28-
php bin/magento maintenance:disable
29-
php bin/magento maintenance:status
30-
```
24+
25+
| Command | Description |
26+
|--------|-------------|
27+
| `setup:config:set` | Sets configuration values like DB or admin URL. |
28+
| `setup:db:status` | Shows database upgrade status. |
29+
| `setup:db:status --show-config` | Shows current DB connection settings. |
30+
| `maintenance:enable` | Enables maintenance mode. |
31+
| `maintenance:disable` | Disables maintenance mode. |
32+
| `maintenance:status` | Shows maintenance mode status. |
3133

3234
---
3335

3436
## Cache Management
3537

36-
```bash
37-
php bin/magento cache:clean
38-
php bin/magento cache:flush
39-
php bin/magento cache:enable
40-
php bin/magento cache:disable
41-
php bin/magento cache:status
42-
```
38+
| Command | Description |
39+
|--------|-------------|
40+
| `cache:clean` | Clears enabled cache types. |
41+
| `cache:flush` | Clears all cache backends (e.g., Redis). |
42+
| `cache:enable` | Enables specified cache types. |
43+
| `cache:disable` | Disables specified cache types. |
44+
| `cache:status` | Displays cache types and their status. |
4345

4446
---
4547

4648
## Index Management
4749

48-
```bash
49-
php bin/magento indexer:reindex
50-
php bin/magento indexer:status
51-
php bin/magento indexer:reset
52-
php bin/magento indexer:info
53-
php bin/magento indexer:show-mode
54-
php bin/magento indexer:set-mode {schedule|realtime} [indexer]
55-
```
50+
| Command | Description |
51+
|--------|-------------|
52+
| `indexer:reindex` | Rebuilds indexers (e.g. product/category data). |
53+
| `indexer:status` | Shows indexer status. |
54+
| `indexer:reset` | Resets indexers that failed. |
55+
| `indexer:info` | Lists all indexers. |
56+
| `indexer:show-mode` | Displays indexer mode (schedule/realtime). |
57+
| `indexer:set-mode {schedule|realtime} [indexer]` | Sets mode for a specific indexer. |
5658

5759
---
5860

5961
## Admin User Management
6062

61-
```bash
62-
php bin/magento admin:user:create
63-
php bin/magento admin:user:unlock [username]
64-
php bin/magento admin:user:delete [username]
65-
```
63+
| Command | Description |
64+
|--------|-------------|
65+
| `admin:user:create` | Creates a new admin user. |
66+
| `admin:user:unlock [username]` | Unlocks a locked admin account. |
67+
| `admin:user:delete [username]` | Deletes an admin user. |
6668

6769
---
6870

6971
## Security
7072

71-
```bash
72-
php bin/magento security:passwords:upgrade
73-
php bin/magento security:hash:upgrade
74-
```
73+
| Command | Description |
74+
|--------|-------------|
75+
| `security:passwords:upgrade` | Upgrades customer password hash format. |
76+
| `security:hash:upgrade` | Upgrades internal hash algorithms for better security. |
7577

7678
---
7779

7880
## Module Management
7981

80-
```bash
81-
php bin/magento module:status
82-
php bin/magento module:enable [Module_Name]
83-
php bin/magento module:disable [Module_Name]
84-
php bin/magento module:uninstall [Module_Name]
85-
```
82+
| Command | Description |
83+
|--------|-------------|
84+
| `module:status` | Lists all modules and their status. |
85+
| `module:enable [Module_Name]` | Enables a module. |
86+
| `module:disable [Module_Name]` | Disables a module. |
87+
| `module:uninstall [Module_Name]` | Uninstalls a module and optionally removes its data. |
8688

8789
---
8890

8991
## Cron & Job Scheduling
9092

91-
```bash
92-
php bin/magento cron:run
93-
php bin/magento cron:install
94-
```
93+
| Command | Description |
94+
|--------|-------------|
95+
| `cron:run` | Executes scheduled cron jobs immediately. |
96+
| `cron:install` | Installs Magento cron jobs into system crontab. |
9597

9698
---
9799

98100
## Cleaning & Logs
99101

100-
```bash
101-
php bin/magento setup:upgrade --keep-generated
102-
php bin/magento dev:log:clean
103-
```
102+
| Command | Description |
103+
|--------|-------------|
104+
| `setup:upgrade --keep-generated` | Keeps generated code during upgrade (for production). |
105+
| `dev:log:clean` | Clears system and exception logs. |
104106

105107
---
106108

107109
## Developer Tools
108110

109111
### Mode & Profiler
110-
```bash
111-
php bin/magento deploy:mode:show
112-
php bin/magento deploy:mode:set {developer|production|default} [-s|--skip-compilation]
113-
php bin/magento dev:profiler:enable
114-
php bin/magento dev:profiler:disable
115-
```
112+
113+
| Command | Description |
114+
|--------|-------------|
115+
| `deploy:mode:show` | Shows current deployment mode. |
116+
| `deploy:mode:set {developer|production|default}` | Changes deployment mode. |
117+
| `--skip-compilation` | Skips DI compilation during mode switch. |
118+
| `dev:profiler:enable` | Enables performance profiler. |
119+
| `dev:profiler:disable` | Disables the profiler. |
116120

117121
### Template & JS
118-
```bash
119-
php bin/magento dev:template-hints:enable
120-
php bin/magento dev:template-hints:disable
121-
php bin/magento dev:source-theme:deploy
122-
```
122+
123+
| Command | Description |
124+
|--------|-------------|
125+
| `dev:template-hints:enable` | Displays template hints in frontend. |
126+
| `dev:template-hints:disable` | Hides template hints. |
127+
| `dev:source-theme:deploy` | Deploys source files (e.g. LESS) for custom themes. |
123128

124129
---
125130

126131
## Store Configuration
127132

128-
```bash
129-
php bin/magento config:set [path] [value]
130-
php bin/magento config:show [path]
131-
php bin/magento config:sensitive:set
132-
php bin/magento config:sensitive:remove
133-
```
133+
| Command | Description |
134+
|--------|-------------|
135+
| `config:set [path] [value]` | Sets a configuration value. |
136+
| `config:show [path]` | Shows a configuration value. |
137+
| `config:sensitive:set` | Marks config value as sensitive (e.g., passwords). |
138+
| `config:sensitive:remove` | Removes sensitive flag from a config. |
134139

135140
---
136141

137142
## EAV (Entity-Attribute-Value)
138143

139-
```bash
140-
php bin/magento eav:attribute:remove
141-
```
144+
| Command | Description |
145+
|--------|-------------|
146+
| `eav:attribute:remove` | Removes a custom attribute from the EAV model. |
142147

143148
---
144149

145150
## Inventory Management
146151

147-
```bash
148-
php bin/magento inventory:reservation:list-inconsistencies
149-
php bin/magento inventory:reservation:create-compensations
150-
```
152+
| Command | Description |
153+
|--------|-------------|
154+
| `inventory:reservation:list-inconsistencies` | Lists mismatches in stock reservations. |
155+
| `inventory:reservation:create-compensations` | Fixes reservation issues by creating compensation records. |
151156

152157
---
153158

154159
## Testing Tools
155160

156-
```bash
157-
php bin/magento dev:tests:run [unit|integration|functional]
158-
```
161+
| Command | Description |
162+
|--------|-------------|
163+
| `dev:tests:run [unit|integration|functional]` | Runs specified test suite. |
159164

160165
---
161166

162167
## Search & Elasticsearch
163168

164-
```bash
165-
php bin/magento indexer:reindex catalogsearch_fulltext
166-
php bin/magento config:set catalog/search/engine elasticsearch7
167-
```
169+
| Command | Description |
170+
|--------|-------------|
171+
| `indexer:reindex catalogsearch_fulltext` | Reindexes product search data. |
172+
| `config:set catalog/search/engine elasticsearch7` | Sets Elasticsearch as the search engine. |
168173

169174
---
170175

171176
## Backup & Restore
172177

173-
```bash
174-
php bin/magento setup:backup --code --media --db
175-
php bin/magento setup:rollback --code-file=... --db-file=...
176-
```
178+
| Command | Description |
179+
|--------|-------------|
180+
| `setup:backup --code --media --db` | Creates backup of codebase, media, and DB. |
181+
| `setup:rollback --code-file=... --db-file=...` | Restores from specified backup files. |
177182

178183
---
179184

180185
## Help
181186

182-
```bash
183-
php bin/magento list
184-
php bin/magento help [command]
185-
```
187+
| Command | Description |
188+
|--------|-------------|
189+
| `list` | Lists all Magento CLI commands. |
190+
| `help [command]` | Shows usage information for a command. |
186191

187192
---
188193

189-
> **Tip**: Always clear cache (`cache:clean` and `cache:flush`) and recompile (`setup:di:compile`) after enabling/disabling modules or making config changes.
194+
> **Tip**: After module changes or config updates, always run `cache:clean`, `cache:flush`, and `setup:di:compile` to apply changes properly.

0 commit comments

Comments
 (0)