Skip to main content

Environment Configuration

Scottsdale Mint uses environment-specific PHP files under config/environments/ to apply per-environment overrides on top of config/application.php. The active environment is determined by WP_ENVIRONMENT_TYPE in .env.


How Environments Are Loadedโ€‹

// config/application.php (simplified)
$env = env('WP_ENVIRONMENT_TYPE', 'production');

// Load environment-specific overrides
$env_config = __DIR__ . "/environments/{$env}.php";
if ( file_exists( $env_config ) ) {
require_once $env_config;
}

config/environments/production.phpโ€‹

<?php
/**
* Production environment configuration.
*/

// Suppress all non-fatal errors in production
error_reporting( E_ERROR );

// Disable Query Monitor
Suma_Config_Helper::disable_plugins([
'query-monitor/query-monitor.php',
]);

// Memory limits for Lambda (4096MB available)
define( 'WP_MEMORY_LIMIT', '4096M' );
define( 'WP_MAX_MEMORY_LIMIT', '4096M' );

config/environments/staging.phpโ€‹

<?php
/**
* Staging environment configuration.
*/

error_reporting( E_ERROR );

// Disable plugins not needed on staging
Suma_Config_Helper::disable_plugins([
'woocommerce-follow-up-emails/woocommerce-follow-up-emails.php',
'mainwp-child/mainwp-child.php',
'walmart-integration-for-woocommerce/walmart-woocommerce-integration.php',
]);

// Staging uses separate Algolia index prefix
define( 'ALGOLIA_INDEX_NAME_PREFIX', 'scottsdale_stg_' );

// Memory limits for Lambda (2048MB on staging)
define( 'WP_MEMORY_LIMIT', '4096M' );
define( 'WP_MAX_MEMORY_LIMIT', '4096M' );

config/environments/development.phpโ€‹

<?php
/**
* Development environment configuration.
*/

// Full error reporting for debugging
define( 'SAVEQUERIES', true ); // For Query Monitor
define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true ); // Show full fatal errors
define( 'SCRIPT_DEBUG', true ); // Load unminified assets

// Allow Jetpack to work locally
define( 'JETPACK_DEV_DEBUG', true );

// Disable unnecessary plugins on dev Lambda environment
Suma_Config_Helper::disable_plugins([
'woocommerce-follow-up-emails/woocommerce-follow-up-emails.php',
'mainwp-child/mainwp-child.php',
'walmart-integration-for-woocommerce/walmart-woocommerce-integration.php',
]);

// Dev-specific Algolia index prefix
define( 'ALGOLIA_INDEX_NAME_PREFIX', 'scottsdale_dev_' );

// Dev database defaults (overridden in .env)
define( 'DB_HOST', env('DB_HOST', 'localhost') );
define( 'DB_NAME', env('DB_NAME', 'wp_scottsdale') );
define( 'DB_USER', env('DB_USER', 'root') );
define( 'DB_PASSWORD', env('DB_PASSWORD', '') );

// Local email via MailHog instead of Mailgun
define( 'WPMS_MAILER', 'smtp' );
define( 'WPMS_SMTP_HOST', '127.0.0.1' );
define( 'WPMS_SMTP_PORT', '2525' );
define( 'WPMS_SMTP_USER', 'scottsdalemint.test' );
define( 'WPMS_SMTP_PASS', '123456' );

// Memory limits (dev Lambda has 2048MB)
define( 'WP_MEMORY_LIMIT', '3G' );
define( 'WP_MAX_MEMORY_LIMIT', '3G' );

config/environments/local.phpโ€‹

The local environment (Laravel Herd) inherits development settings and additionally:

// Local Algolia prefix
define( 'ALGOLIA_INDEX_NAME_PREFIX', 'scottsdale_local_v2_' );

// Local Redis (no AUTH token)
define( 'WP_REDIS_CLIENT', env('WP_REDIS_CLIENT', 'phpredis') );

Environment Differences Summaryโ€‹

Settinglocaldevelopmentstagingproduction
WP_DEBUGtruetruefalsefalse
SCRIPT_DEBUGtruetruefalsefalse
SAVEQUERIEStruetruefalsefalse
PHP error reportingE_ALLE_ALLE_ERRORE_ERROR
Algolia prefixscottsdale_local_v2_scottsdale_dev_scottsdale_stg_scottsdale_prod_
Email routingMailHog (SMTP)MailHog (SMTP)MailgunMailgun
Redis clientphpredisphpredis/relayrelayrelay
Redis compressionnonenonezstdzstd
Memory limitHerd (unlimited)3GB4GB4GB
AvaTax commitsDisabledDisabledDisabledEnabled
Kount pluginEnabledEnabledEnabledDisabled (plugin disabler)
Query MonitorEnabledEnabledEnabledDisabled (plugin disabler)
Walmart pluginDisabledDisabledDisabledDisabled
Follow-up EmailsEnabledDisabledDisabledDisabled
MainWP ChildEnabledDisabledDisabledDisabled

Suma Patches Dev Module (class-dev.php)โ€‹

The suma-patches plugin's Dev class applies additional per-environment behaviors using WordPress hooks. It runs on all non-production environments to:

  • Override the Algolia index name prefix in the database (via pre_option filter)
  • Override admin email (prevents staging from emailing real customers)
  • Add noindex meta tag to prevent staging/dev indexing by search engines
  • Disable AvaTax order recording and commit (wc_avatax_record_calculations = 'no')
  • Clear Google Analytics tracking code (prevents staging events polluting GA)
  • Configure WP Mail SMTP to use MailHog locally

Adding a New Environment Overrideโ€‹

  1. Create config/environments/{environment-name}.php
  2. Set WP_ENVIRONMENT_TYPE={environment-name} in .env
  3. Add any define() calls or Suma_Config_Helper::disable_plugins() calls
caution

Environment files are loaded via require_once โ€” they run at WordPress bootstrap time, before plugins_loaded. Only use define(), Suma_Config_Helper, and similar pre-boot operations here.