Its my first project in magento.
I am confuse about deployment and compilation.
When i do compilation every time after changes i got some error.
Also deployment have many more time memory failed and execution error.
I m using these steps after every changes.
sudo rm -rf var/di var/generation/ var/cache and var/page_cache pub/static/frontend pub/static/_requirejs/ pub/static/adminhtml
sudo chmod -R 777 var pub lib app/etc
php -dmemory_limit=2G -dmaximum_execution_time=1800 bin/magento setup:upgrade
php -dmemory_limit=2G bin/magento indexer:reindex
php -dmemory_limit=2G -dmaximum_execution_time=1800 bin/magento deploy:mode:set production -s
php -dmemory_limit=2G -dmaximum_execution_time=1800 bin/magento setup:di:compile
#php -d allowedmax_execution_time=3000 bin/magento setup:static-content:deploy
php -f bin/magento setup:static-content:deploy
But in deployment and comilation its failed every time due to memeory and execution error.
My question is when compilation and deployment required in magento 2 .
Best Answer
Compilation and deployment required in Magento 2 only when you need run it in "production mode". But if you develop module you need to switch to "developer mode" and static content will be automatically redeployed on request (but you need to cleanup pub/static only first time after switch)
As documentation says: