<?php
/**
* Environment Configuration
* {{ ansible_managed }}
*
* This file contains environment-specific configuration settings.
*/
// Application environment
define('APP_ENV', '{{ app_environment | default("production") }}');
// Application name and version
define('APP_NAME', '{{ app_name | default("AWS LAMP Stack") }}');
define('APP_VERSION', '{{ app_version | default("1.0.0") }}');
// Debug mode (should be false in production)
define('APP_DEBUG', {{ app_debug | default('false') }});
// Base URL
define('APP_URL', '{{ app_url | default("http://localhost") }}');
// Timezone settings
define('APP_TIMEZONE', '{{ app_timezone | default("UTC") }}');
date_default_timezone_set(APP_TIMEZONE);
// Security settings
define('APP_KEY', '{{ app_key | default("") }}');
define('SESSION_SECURE', {{ app_session_secure | default('true') }});
define('COOKIE_SECURE', {{ app_cookie_secure | default('true') }});
define('COOKIE_HTTP_ONLY', {{ app_cookie_http_only | default('true') }});
define('COOKIE_SAME_SITE', '{{ app_cookie_same_site | default("Lax") }}');
// CORS settings
define('CORS_ALLOWED_ORIGINS', '{{ app_cors_allowed_origins | default("*") }}');
define('CORS_ALLOWED_METHODS', '{{ app_cors_allowed_methods | default("GET, POST, PUT, DELETE, OPTIONS") }}');
define('CORS_ALLOWED_HEADERS', '{{ app_cors_allowed_headers | default("Content-Type, Authorization") }}');
define('CORS_EXPOSED_HEADERS', '{{ app_cors_exposed_headers | default("") }}');
define('CORS_MAX_AGE', {{ app_cors_max_age | default(86400) }});
define('CORS_SUPPORTS_CREDENTIALS', {{ app_cors_supports_credentials | default('false') }});
// File upload settings
define('UPLOAD_MAX_SIZE', {{ app_upload_max_size | default(10485760) }}); // 10MB
define('UPLOAD_ALLOWED_TYPES', '{{ app_upload_allowed_types | default("jpg,jpeg,png,gif,pdf,doc,docx,xls,xlsx,zip,txt") }}');
define('UPLOAD_PATH', '{{ app_upload_path | default("uploads") }}');
// Logging settings
define('LOG_ENABLED', {{ app_log_enabled | default('true') }});
define('LOG_LEVEL', '{{ app_log_level | default("error") }}');
define('LOG_PATH', '{{ app_log_path | default("/var/log/app") }}');
define('LOG_MAX_FILES', {{ app_log_max_files | default(30) }});
// Cache settings
define('CACHE_ENABLED', {{ app_cache_enabled | default('true') }});
define('CACHE_TTL', {{ app_cache_ttl | default(3600) }});
define('CACHE_PATH', '{{ app_cache_path | default("/tmp/app_cache") }}');
// Session settings
define('SESSION_NAME', '{{ app_session_name | default("LAMP_SESSION") }}');
define('SESSION_LIFETIME', {{ app_session_lifetime | default(7200) }});
define('SESSION_PATH', '{{ app_session_path | default("/") }}');
define('SESSION_DOMAIN', '{{ app_session_domain | default("") }}');
// AWS settings
define('AWS_REGION', '{{ aws_region | default("us-east-1") }}');
define('AWS_ACCESS_KEY_ID', '{{ aws_access_key_id | default("") }}');
define('AWS_SECRET_ACCESS_KEY', '{{ aws_secret_access_key | default("") }}');
// CloudWatch settings
define('CLOUDWATCH_ENABLED', {{ cloudwatch_enabled | default('true') }});
define('CLOUDWATCH_LOG_GROUP', '{{ cloudwatch_log_group | default("/aws/ec2/lamp") }}');
define('CLOUDWATCH_LOG_STREAM', '{{ cloudwatch_log_stream | default("php-app") }}');
// S3 settings
define('S3_BUCKET', '{{ s3_bucket | default("") }}');
define('S3_PREFIX', '{{ s3_prefix | default("") }}');
define('S3_URL', '{{ s3_url | default("") }}');
// CloudFront settings
define('CLOUDFRONT_ENABLED', {{ cloudfront_enabled | default('false') }});
define('CLOUDFRONT_DOMAIN', '{{ cloudfront_domain | default("") }}');
define('CLOUDFRONT_KEY_PAIR_ID', '{{ cloudfront_key_pair_id | default("") }}');
define('CLOUDFRONT_PRIVATE_KEY', '{{ cloudfront_private_key | default("") }}');
// Route53 settings
define('ROUTE53_DOMAIN', '{{ route53_domain | default("") }}');
define('ROUTE53_ZONE_ID', '{{ route53_zone_id | default("") }}');
// RDS settings
define('RDS_ENABLED', {{ rds_enabled | default('true') }});
define('RDS_INSTANCE', '{{ rds_instance | default("") }}');
// EFS settings
define('EFS_ENABLED', {{ efs_enabled | default('true') }});
define('EFS_ID', '{{ efs_id | default("") }}');
define('EFS_MOUNT_POINT', '{{ efs_mount_point | default("/mnt/efs") }}');
// ALB settings
define('ALB_ENABLED', {{ alb_enabled | default('true') }});
define('ALB_NAME', '{{ alb_name | default("") }}');
define('ALB_DNS_NAME', '{{ alb_dns_name | default("") }}');
// WAF settings
define('WAF_ENABLED', {{ waf_enabled | default('true') }});
define('WAF_ACL_ID', '{{ waf_acl_id | default("") }}');
// Auto Scaling settings
define('ASG_ENABLED', {{ asg_enabled | default('true') }});
define('ASG_NAME', '{{ asg_name | default("") }}');
define('ASG_MIN_SIZE', {{ asg_min_size | default(2) }});
define('ASG_MAX_SIZE', {{ asg_max_size | default(10) }});
define('ASG_DESIRED_CAPACITY', {{ asg_desired_capacity | default(2) }});
// Health check settings
define('HEALTH_CHECK_PATH', '{{ health_check_path | default("/health.php") }}');
define('HEALTH_CHECK_INTERVAL', {{ health_check_interval | default(30) }});
define('HEALTH_CHECK_TIMEOUT', {{ health_check_timeout | default(5) }});
define('HEALTH_CHECK_HEALTHY_THRESHOLD', {{ health_check_healthy_threshold | default(2) }});
define('HEALTH_CHECK_UNHEALTHY_THRESHOLD', {{ health_check_unhealthy_threshold | default(2) }});
// API settings
define('API_ENABLED', {{ api_enabled | default('false') }});
define('API_VERSION', '{{ api_version | default("v1") }}');
define('API_PREFIX', '{{ api_prefix | default("api") }}');
define('API_DEBUG', {{ api_debug | default('false') }});
define('API_THROTTLE', {{ api_throttle | default(60) }});
// Email settings
define('MAIL_ENABLED', {{ mail_enabled | default('false') }});
define('MAIL_HOST', '{{ mail_host | default("smtp.example.com") }}');
define('MAIL_PORT', {{ mail_port | default(587) }});
define('MAIL_USERNAME', '{{ mail_username | default("") }}');
define('MAIL_PASSWORD', '{{ mail_password | default("") }}');
define('MAIL_ENCRYPTION', '{{ mail_encryption | default("tls") }}');
define('MAIL_FROM_ADDRESS', '{{ mail_from_address | default("noreply@example.com") }}');
define('MAIL_FROM_NAME', '{{ mail_from_name | default("LAMP Application") }}');
// Custom application settings
{% for key, value in app_custom_settings | default({}) | dictsort %}
define('{{ key }}', {% if value is string %}'{{ value }}'{% else %}{{ value }}{% endif %});
{% endfor %}
// Load environment-specific overrides if they exist
$envSpecificFile = __DIR__ . '/env.' . strtolower(APP_ENV) . '.php';
if (file_exists($envSpecificFile)) {
require_once $envSpecificFile;
}