Skip to content
beginner Phase 75 · Debugging Basics

Developer Mode

30m
1 problems
Topic Progress 0%

Enabling Developer Mode

Switch to Developer Mode

# Enable developer mode
bin/magento deploy:mode:set developer

# Verify current mode
bin/magento deploy:mode:show

# Switch to production mode
bin/magento deploy:mode:set production

Mode Differences

// Developer Mode:
// - Auto-compilation disabled
// - Error display enabled
// - Static files not cached
// - Detailed error messages
// - File watching enabled

// Production Mode:
// - Auto-compilation enabled
// - Error display disabled
// - Static files cached
// - Minimal error messages
// - Performance optimized

Environment Configuration

// app/etc/env.php
return [
    'MAGE_MODE' => 'developer', // or 'production'
    
    'system' => [
        'default' => [
            'dev' => [
                'debug' => [
                    'debug_logging' => 1,
                    'profiler' => 0,
                ],
                'template' => [
                    'allow_symlink' => 1,
                ],
            ],
        ],
    ],
];

Key Points

  • Developer mode enables detailed error display
  • Never use developer mode in production
  • Static content deployment differs by mode
  • Developer mode has performance overhead

Static Content Deployment

Deploy Static Files

# Deploy all static content
bin/magento setup:static-content:deploy

# Deploy for specific theme
bin/magento setup:static-content:deploy -f Magento/luma

# Deploy for specific locale
bin/magento setup:static-content:deploy en_US

# Deploy with jobs (faster)
bin/magento setup:static-content:deploy -j 4

# Quick deploy (developer mode)
bin/magento setup:static-content:deploy --no-parent -t Magento/luma

Static Content Configuration

// app/etc/env.php
return [
    'static' => [
        'version' => '1.0.0',
    ],
    
    'deploy' => [
        'hoist' => 1,
    ],
];

File Symlinks

# Enable symlinks for development
bin/magento config:set dev/template/allow_symlink 1

# Check symlink status
bin/magento config:show dev/template/allow_symlink

Key Points

  • Deploy after theme or LESS/CSS changes
  • Use jobs flag for faster deployment
  • Symlinks speed up development
  • Cache static files in production

Error Display Settings

PHP Error Configuration

; php.ini settings for development
display_errors = On
error_reporting = E_ALL
log_errors = On
error_log = /var/log/php_errors.log

; Production settings
display_errors = Off
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
log_errors = On

Magento Error Handler

// app/bootstrap.php
\Magento\Framework\App\Bootstrap::run($initParams);

// Custom error handler
set_error_handler(function($errno, $errstr, $errfile, $errline) {
    $logger = \Magento\Framework\App\Bootstrap::getObjectManager()
        ->get(\Psr\Log\LoggerInterface::class);
    
    $logger->error($errstr, [
        'file' => $errfile,
        'line' => $errline,
    ]);
    
    return true;
});

Custom Error Page

// app/code/Vendor/Module/view/frontend/templates/error/404.phtml
<div class="page-not-found">
    <h1>404</h1>
    <p>Page not found.</p>
    <a href="<?= $block->getBaseUrl() ?>">Return to Home</a>
</div>

Key Points

  • Developer mode shows detailed errors
  • Production mode hides errors from users
  • Always log errors even when hidden
  • Custom error pages improve UX

Practice Problems

0 / 1 solved
Mode Configuration

Configure a Magento store for development with proper error display and static content settings.

Solution
# 1. Set developer mode
bin/magento deploy:mode:set developer

# 2. Verify mode
bin/magento deploy:mode:show

# 3. Enable symlinks
bin/magento config:set dev/template/allow_symlink 1

# 4. Deploy static content
bin/magento setup:static-content:deploy -f

# 5. Clean cache
bin/magento cache:clean

Quiz

1. What does developer mode enable?

Question 1 options

2. How do you deploy static content?

Question 2 options

3. When should you use production mode?

Question 3 options

4. What is the benefit of symlinks in development?

Question 4 options

Flashcards

Question

Developer mode command?

Answer

bin/magento deploy:mode:set developer

Question

Static content deploy?

Answer

bin/magento setup:static-content:deploy

Question

Developer mode benefit?

Answer

Detailed error display for debugging

Question

Production mode feature?

Answer

Cached static files, hidden errors

Revision Notes

Key Takeaways

  • 1. Developer mode shows detailed errors and disables caching
  • 2. Use bin/magento deploy:mode:set to switch modes
  • 3. Deploy static content after theme changes
  • 4. Never use developer mode in production

Interview Tips

  • Explain differences between developer and production mode
  • Discuss when to deploy static content
  • Know error display configuration

Cheat Sheet

Developer Mode

  • Set: bin/magento deploy:mode:set developer
  • Deploy: bin/magento setup:static-content:deploy
  • Errors: displayed in developer mode
  • Symlinks: enabled for faster dev