Useful Magento 2 Commands for Development
Essential Magento 2 CLI commands for developer mode, debugging, module management, cron, and log handling.
Important Commands
-
Enable Developer Mode
php bin/magento deploy:mode:set developer -
Enable / Disable Template Hints
php bin/magento dev:template-hints:enable php bin/magento dev:template-hints:disable -
Disable Two-Factor Authentication
php bin/magento module:disable Magento_TwoFactorAuth -
Module Upgrade & Setup Commands
php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento indexer:reindex php bin/magento cache:flush sudo chmod -R 777 var sudo chmod -R 777 pub -
Run Cron Job
php bin/magento cron:run -
Delete All .log Files in Folder
find . -name "*.log" -delete -
Empty a Specific .log File
echo -n "" > filename.log
Important Notes
- Use developer mode only in development environments.
- Avoid using
777permissions in production for security reasons. - Always clear cache after major changes.
- Set up cron jobs properly for production stores.