Using console commands

Working with CLI

We have our PHP compiled, Composer installed, Magento 2 installed. But how access them? Everything is scattered across the file system.
That is where CLI comes in handy. It provides aliases for PHP, Composer and Magento in your project. We can open it by running a command:
1
npm run cli # for NPM
2
yarn cli # for Yarn
Copied!
Now we have access to PHP, Composer and Magento, we can install PHP dependencies, upgrade Magento and so on.
1
php -v
2
> PHP 7.4.13 (cli) ...
3
4
composer --version
5
> Composer version 1.10.19
6
7
# Can be used with alias
8
c --version
9
> Composer version 1.10.19
10
11
magento setup:upgrade
12
> Magento upgrade output ...
13
14
# Can be used with alias
15
m se:up
16
> Magento upgrade output ...
Copied!

Common Usage

Flushing Magento cache
1
magento cache:flush
2
3
# or with aliases and shortcuts
4
m c:f
Copied!
Magento upgrade
1
magento setup:upgrade
2
3
# or with aliases and shortcuts
4
m se:up
Copied!
Upgrading Composer dependencies
1
composer upgrade
2
3
# or with alias
4
c upgrade
Copied!
Last modified 11mo ago