PART 1.2.1.3 – Commands in workflow

Command relevant for frontend

m2 = php bin/magento, enter m2 in terminal to see all available commands

Cache

Turn off

php bin/magento cache:disable | m2 cache:disable

Turn on

php bin/magento cache:enable | m2 cache:enable

Flush all

php bin/magento cache:flush | m2 cache:flush

Cleaning cache, page-cache and merged requirejs-config

m2-qc

Cleaning cache, page-cache and merged requirejs-config +  

cleraning generated code and non-symlinked files from static

m2-qcc

Clean all

m2-qccc

 

To avoid issues with static files, you must clean the old files to make sure you get all the changes for the new module. Using m2-qccc after installing a new module is recommended.

Grunt

Removes the theme related static files in the pub/static and var directories.

grunt clean:<theme>

Republishes symlinks to the source files to the pub/static/frontend/<Vendor>/<theme>/<locale> directory.

grunt exec:<theme>

Compiles .css files using the symlinks published in the pub/static/frontend/<Vendor>/<theme>/<locale> directory

grunt less:<theme>

Tracks the changes in the source files, recompiles.css files, and reloads the page in the browser pages (Doesn’t work very well with devbox)

grunt watch

Merging and minification

Disable merging and minification

m0

Enable merging and minification

m1

Remember to run m0 after importing project db to local machine. Development is painfully slow if merging and minification is enabled on local environments. 

Xdebug

Disable xdebug

vd0

Enable xdebug

vd1

Disable xdebug if you’re not actively debugging and are planning to use Magento admin. Remember to enable it if you need to debug something.

Reindex

Reindex

php bin/magento indexer:reindex | m2 indexer:reindex

After adding the new module

Upgrade

m2-qccc

After running this command you’ll be prompted to run the command “php bin/magento setup:static-content:deploy”, there is no need to do this in a local environment since you’ll probably have grunt or gulp for this. 

Deploy static file

Deploy static files

php bin/magento setup:static-content:deploy

Usually not needed

Practical examples

What commands you need to run depends on what caches you have disabled in Magento.

Adding new files: 

grunt

gulp

m2-qccc

grunt exec:feworkshop

m2 dev:source-theme:deploy –theme=”Vaimo/feworkshop” –locale=”en_US” –area=”frontend”

grunt less:feworkshop

gulp

grunt watch (or use watch from phpStorm which is faster)

gulp watch

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s