Skip to content

Environment Configuration

This guide explains environment-specific configurations in LamaPress.

Table of Contents


Overview

LamaPress supports environment-specific configurations for development, staging, and production environments.

Environment Detection

Environment Helper Functions

Use helper functions to detect environment:

php
if (llIsLocal()) {
    // Local development code
}

if (llIsStaging()) {
    // Staging-specific code
}

if (llIsProduction()) {
    // Production-specific code
}

Available functions:

  • llIsLocal() - Returns true if running on local environment (detects .test domain extension)
  • llIsStaging() - Returns true if running on staging environment (detects .dev domain extension)
  • llIsProduction() - Returns true if running on production environment (not local or staging)

How it works: Environment detection is based on the server name extension:

  • Local: .test (Laravel Herd default)
  • Staging: .dev (Laravel Forge staging domains)
  • Production: All other domains

WordPress Constants

Debug Settings

Development:

php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
define('SCRIPT_DEBUG', true);

Production:

php
define('WP_DEBUG', false);
define('WP_DEBUG_LOG', false);
define('WP_DEBUG_DISPLAY', false);
define('SCRIPT_DEBUG', false);

Database Settings

Configure database per environment:

php
define('DB_NAME', 'database_name');
define('DB_USER', 'database_user');
define('DB_PASSWORD', 'database_password');
define('DB_HOST', 'database_host');

Security Settings

Security settings:

php
define('DISALLOW_FILE_EDIT', true);
define('FORCE_SSL_ADMIN', true);

Vite Configuration

Development Mode

Development mode uses Vite dev server:

bash
npm run dev

Features:

  • Hot module replacement
  • Source maps
  • Fast refresh

Production Mode

Production mode builds optimized assets:

bash
npm run build

Features:

  • Minified code
  • Optimized assets
  • Code splitting

Environment Files

.env File

Use .env for sensitive data (not committed):

ini
DB_NAME=database_name
DB_USER=database_user
DB_PASSWORD=database_password

Load in wp-config.php:

php
if (file_exists(__DIR__ . '/.env')) {
    $env = parse_ini_file(__DIR__ . '/.env');
    foreach ($env as $key => $value) {
        define($key, $value);
    }
}

wp-config.php

Configure WordPress in wp-config.php:

php
// Database
define('DB_NAME', 'database_name');
define('DB_USER', 'database_user');
define('DB_PASSWORD', 'database_password');
define('DB_HOST', 'localhost');

// Debug
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);

// Security
define('DISALLOW_FILE_EDIT', true);

Best Practices

1. Use Environment Variables

Use environment variables for configuration:

  • Database credentials
  • API keys
  • Environment settings

2. Never Commit Secrets

Never commit sensitive data:

  • Add .env to .gitignore
  • Use environment variables
  • Store secrets securely

3. Document Configuration

Document environment setup:

  • Required variables
  • Configuration steps
  • Environment differences

Next Steps:

Released under the MIT License.