Useful Magento 2 Commands for Development

Essential Magento 2 CLI commands for developer mode, debugging, module management, cron, and log handling.

Important Commands

  1. Enable Developer Mode
    php bin/magento deploy:mode:set developer
  2. Enable / Disable Template Hints
    
    php bin/magento dev:template-hints:enable
    php bin/magento dev:template-hints:disable
            
  3. Disable Two-Factor Authentication
    php bin/magento module:disable Magento_TwoFactorAuth
  4. 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
            
  5. Run Cron Job
    php bin/magento cron:run
  6. Delete All .log Files in Folder
    find . -name "*.log" -delete
  7. Empty a Specific .log File
    echo -n "" > filename.log

Important Notes

  • Use developer mode only in development environments.
  • Avoid using 777 permissions in production for security reasons.
  • Always clear cache after major changes.
  • Set up cron jobs properly for production stores.