Class PhpContainerFactory

java.lang.Object
com.cloudforgeci.api.compute.PhpContainerFactory

public final class PhpContainerFactory extends Object
Factory for creating PHP container configurations for CMS platforms.

Generates container environment variables, PHP-FPM configuration, and NGINX configuration for PHP-based CMS deployments on Fargate.

Usage Example:

CmsSpec wordpress = new WordPressApplicationSpec();
PhpRuntimeConfig config = PhpRuntimeConfig.forWordPress();

Map<String, String> env = PhpContainerFactory.createEnvironment(wordpress, config);
String nginxConf = PhpContainerFactory.generateNginxConfig(wordpress);
Since:
3.1.0
  • Method Details

    • createEnvironment

      public static Map<String,String> createEnvironment(CmsSpec spec, PhpRuntimeConfig config)
      Generate PHP container environment variables.

      Creates environment variables for:

      • PHP memory and execution limits
      • OPcache settings
      • Upload limits
      • Timezone
      Parameters:
      spec - the CMS specification
      config - the PHP runtime configuration
      Returns:
      map of environment variables
    • generateFpmConfig

      public static String generateFpmConfig(CmsSpec spec, PhpRuntimeConfig config)
      Generate PHP-FPM configuration file content.
      Parameters:
      spec - the CMS specification
      config - the PHP runtime configuration
      Returns:
      PHP-FPM pool configuration content
    • getBaseImage

      public static String getBaseImage(String phpVersion)
      Get the base container image for the specified PHP version.
      Parameters:
      phpVersion - PHP version (e.g., "8.2", "8.1")
      Returns:
      Docker image tag
    • getCmsImage

      public static String getCmsImage(CmsSpec spec)
      Get the official CMS container image if available.
      Parameters:
      spec - the CMS specification
      Returns:
      container image reference
    • generateNginxConfig

      public static String generateNginxConfig(CmsSpec spec)
      Generate NGINX configuration for PHP-FPM reverse proxy.
      Parameters:
      spec - the CMS specification
      Returns:
      NGINX configuration content
    • generateWordPressNginxConfig

      public static String generateWordPressNginxConfig(String documentRoot, int port, boolean isMultisite)
      Generate WordPress-specific NGINX configuration.
      Parameters:
      documentRoot - document root path
      port - listen port
      isMultisite - whether multisite is enabled
      Returns:
      WordPress NGINX configuration
    • generateMagentoNginxConfig

      public static String generateMagentoNginxConfig(String documentRoot, int port)
      Generate Magento-specific NGINX configuration.
      Parameters:
      documentRoot - document root path (typically /var/www/html)
      port - listen port
      Returns:
      Magento NGINX configuration
    • createDatabaseEnvironment

      public static Map<String,String> createDatabaseEnvironment(CmsSpec spec, String dbHost, int dbPort, String dbName, String dbUser)
      Generate environment variables for database connection.
      Parameters:
      spec - the CMS specification
      dbHost - database hostname
      dbPort - database port
      dbName - database name
      dbUser - database username
      Returns:
      map of database environment variables
    • createRedisEnvironment

      public static Map<String,String> createRedisEnvironment(CmsSpec spec, String redisHost, int redisPort)
      Generate environment variables for Redis object cache.
      Parameters:
      spec - the CMS specification
      redisHost - Redis hostname
      redisPort - Redis port
      Returns:
      map of Redis environment variables