Skip to content

Debugging

This guide explains debugging techniques and tools in LamaPress.

Table of Contents


Overview

LamaPress provides various debugging tools and techniques for troubleshooting issues during development.

WordPress Debugging

Enable Debug Mode

Enable WordPress debugging in wp-config.php:

php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false); // Don't display on frontend
define('SCRIPT_DEBUG', true); // Use non-minified scripts

Debug Log

Check debug log:

bash
tail -f wp-content/debug.log

Location: wp-content/debug.log

Error Display

Display errors on screen (development only):

php
define('WP_DEBUG_DISPLAY', true);
ini_set('display_errors', 1);

JavaScript Debugging

Browser Console

Use browser console for debugging:

javascript
console.log('Debug message', variable)
console.error('Error message', error)
console.warn('Warning message')

Source Maps

Source maps are enabled in development:

  • Open DevTools
  • Go to Sources tab
  • Navigate to original source files
  • Set breakpoints

Breakpoints

Set breakpoints in browser:

  1. Open DevTools
  2. Go to Sources tab
  3. Find source file
  4. Click line number to set breakpoint

PHP Debugging

Error Logging

Log errors to file:

php
error_log('Debug message: ' . print_r($variable, true));

Variable Dumping

Use dd() helper for debugging:

php
dd($variable); // Dump and die

Note: Only use in development.

ACF Debugging

Field Inspection

Inspect ACF fields:

php
$field = llField('title', $key, $section);
var_dump($field); // Or use dd($field)

Field Registration

Check if fields are registered:

  1. Go to WordPress admin
  2. Navigate to Custom Fields
  3. Check field groups
  4. Verify field keys

Build Debugging

Build Errors

Check build output:

bash
npm run build

Common issues:

  • Syntax errors
  • Missing imports
  • Type errors

Asset Issues

Verify assets are loading:

  1. Check browser Network tab
  2. Verify asset URLs
  3. Check Vite manifest
  4. Verify build output

Best Practices

1. Enable Debug in Development

Always enable debug mode in development:

php
define('WP_DEBUG', true);

2. Check Console Regularly

Check browser console for errors:

  • JavaScript errors
  • Network errors
  • Console warnings

3. Use Source Maps

Use source maps for debugging:

  • Original source files
  • Breakpoints
  • Variable inspection

Next Steps:

Released under the MIT License.