Record Class PhpRuntimeConfig

java.lang.Object
java.lang.Record
com.cloudforge.core.interfaces.PhpRuntimeConfig
Record Components:
version - PHP version (e.g., "8.2", "8.1")
extensions - List of required PHP extensions
phpIni - Custom php.ini settings
fpmConfig - PHP-FPM pool configuration
opcacheConfig - OPcache settings
memoryLimit - PHP memory_limit in MB
maxExecutionTime - max_execution_time in seconds
uploadMaxFilesize - upload_max_filesize in MB
postMaxSize - post_max_size in MB

public record PhpRuntimeConfig(String version, List<String> extensions, Map<String,String> phpIni, Map<String,String> fpmConfig, Map<String,String> opcacheConfig, int memoryLimit, int maxExecutionTime, int uploadMaxFilesize, int postMaxSize) extends Record
PHP runtime configuration for CMS deployments.

This record encapsulates all PHP-related configuration including:

  • PHP version and extensions
  • PHP-FPM pool settings
  • OPcache configuration
  • Memory and execution limits
  • Upload size limits

Usage Example:

PhpRuntimeConfig config = PhpRuntimeConfig.defaults()
    .withVersion("8.2")
    .withMemoryLimit(512)
    .withExtensions(List.of("mysqli", "gd", "redis"));
Since:
3.1.0
  • Field Details

    • COMMON_EXTENSIONS

      public static final List<String> COMMON_EXTENSIONS
      Common PHP extensions required by most CMS platforms.
    • IMAGE_EXTENSIONS

      public static final List<String> IMAGE_EXTENSIONS
      Extensions for image processing (beyond basic GD).
    • CACHE_EXTENSIONS

      public static final List<String> CACHE_EXTENSIONS
      Extensions for caching backends.
    • ECOMMERCE_EXTENSIONS

      public static final List<String> ECOMMERCE_EXTENSIONS
      Extensions for e-commerce platforms (encryption, math).
  • Constructor Details

    • PhpRuntimeConfig

      public PhpRuntimeConfig(String version, List<String> extensions, Map<String,String> phpIni, Map<String,String> fpmConfig, Map<String,String> opcacheConfig, int memoryLimit, int maxExecutionTime, int uploadMaxFilesize, int postMaxSize)
      Creates an instance of a PhpRuntimeConfig record class.
      Parameters:
      version - the value for the version record component
      extensions - the value for the extensions record component
      phpIni - the value for the phpIni record component
      fpmConfig - the value for the fpmConfig record component
      opcacheConfig - the value for the opcacheConfig record component
      memoryLimit - the value for the memoryLimit record component
      maxExecutionTime - the value for the maxExecutionTime record component
      uploadMaxFilesize - the value for the uploadMaxFilesize record component
      postMaxSize - the value for the postMaxSize record component
  • Method Details

    • defaults

      public static PhpRuntimeConfig defaults()
      Creates a default PHP runtime configuration suitable for most CMS platforms.

      Default values:

      • PHP 8.2
      • Common extensions + redis
      • 256MB memory limit
      • 300 second max execution time
      • 64MB upload limit
      Returns:
      default PhpRuntimeConfig
    • forWordPress

      public static PhpRuntimeConfig forWordPress()
      Creates a configuration optimized for WordPress.
      Returns:
      WordPress-optimized PhpRuntimeConfig
    • forEcommerce

      public static PhpRuntimeConfig forEcommerce()
      Creates a configuration optimized for WooCommerce/e-commerce.
      Returns:
      E-commerce optimized PhpRuntimeConfig
    • forMagento

      public static PhpRuntimeConfig forMagento()
      Creates a configuration optimized for Magento 2.
      Returns:
      Magento-optimized PhpRuntimeConfig
    • forDrupal

      public static PhpRuntimeConfig forDrupal()
      Creates a configuration for Drupal.
      Returns:
      Drupal-optimized PhpRuntimeConfig
    • forSocial

      public static PhpRuntimeConfig forSocial()
      Creates a configuration for social networking platforms (Dolphin/UNA, HumHub).
      Returns:
      Social platform optimized PhpRuntimeConfig
    • withVersion

      public PhpRuntimeConfig withVersion(String version)
      Returns a new config with the specified PHP version.
      Parameters:
      version - PHP version (e.g., "8.2", "8.1")
      Returns:
      new PhpRuntimeConfig with updated version
    • withExtensions

      public PhpRuntimeConfig withExtensions(List<String> extensions)
      Returns a new config with the specified extensions.
      Parameters:
      extensions - list of PHP extension names
      Returns:
      new PhpRuntimeConfig with updated extensions
    • withAdditionalExtensions

      public PhpRuntimeConfig withAdditionalExtensions(List<String> additionalExtensions)
      Returns a new config with additional extensions added.
      Parameters:
      additionalExtensions - extensions to add
      Returns:
      new PhpRuntimeConfig with extensions added
    • withPhpIni

      public PhpRuntimeConfig withPhpIni(Map<String,String> phpIni)
      Returns a new config with the specified php.ini settings.
      Parameters:
      phpIni - map of php.ini key-value pairs
      Returns:
      new PhpRuntimeConfig with updated php.ini
    • withFpmConfig

      public PhpRuntimeConfig withFpmConfig(Map<String,String> fpmConfig)
      Returns a new config with the specified PHP-FPM settings.
      Parameters:
      fpmConfig - map of PHP-FPM configuration
      Returns:
      new PhpRuntimeConfig with updated FPM config
    • withOpcacheConfig

      public PhpRuntimeConfig withOpcacheConfig(Map<String,String> opcacheConfig)
      Returns a new config with the specified OPcache settings.
      Parameters:
      opcacheConfig - map of OPcache configuration
      Returns:
      new PhpRuntimeConfig with updated OPcache config
    • withMemoryLimit

      public PhpRuntimeConfig withMemoryLimit(int memoryLimit)
      Returns a new config with the specified memory limit.
      Parameters:
      memoryLimit - memory_limit in MB
      Returns:
      new PhpRuntimeConfig with updated memory limit
    • withMaxExecutionTime

      public PhpRuntimeConfig withMaxExecutionTime(int maxExecutionTime)
      Returns a new config with the specified max execution time.
      Parameters:
      maxExecutionTime - max_execution_time in seconds
      Returns:
      new PhpRuntimeConfig with updated execution time
    • withUploadMaxFilesize

      public PhpRuntimeConfig withUploadMaxFilesize(int uploadMaxFilesize)
      Returns a new config with the specified upload max filesize.
      Parameters:
      uploadMaxFilesize - upload_max_filesize in MB
      Returns:
      new PhpRuntimeConfig with updated upload size
    • withPostMaxSize

      public PhpRuntimeConfig withPostMaxSize(int postMaxSize)
      Returns a new config with the specified post max size.
      Parameters:
      postMaxSize - post_max_size in MB
      Returns:
      new PhpRuntimeConfig with updated post size
    • getBaseImage

      public String getBaseImage()
      Returns the base Docker image for this PHP version.
      Returns:
      PHP-FPM Alpine image tag
    • getPoolName

      public String getPoolName()
      Returns the PHP-FPM pool name.
      Returns:
      pool name (default: "www")
    • generatePhpIni

      public String generatePhpIni()
      Generates php.ini content from configuration.
      Returns:
      php.ini content as string
    • generateFpmPoolConfig

      public String generateFpmPoolConfig()
      Generates PHP-FPM pool configuration content.
      Returns:
      PHP-FPM pool configuration as string
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • version

      public String version()
      Returns the value of the version record component.
      Returns:
      the value of the version record component
    • extensions

      public List<String> extensions()
      Returns the value of the extensions record component.
      Returns:
      the value of the extensions record component
    • phpIni

      public Map<String,String> phpIni()
      Returns the value of the phpIni record component.
      Returns:
      the value of the phpIni record component
    • fpmConfig

      public Map<String,String> fpmConfig()
      Returns the value of the fpmConfig record component.
      Returns:
      the value of the fpmConfig record component
    • opcacheConfig

      public Map<String,String> opcacheConfig()
      Returns the value of the opcacheConfig record component.
      Returns:
      the value of the opcacheConfig record component
    • memoryLimit

      public int memoryLimit()
      Returns the value of the memoryLimit record component.
      Returns:
      the value of the memoryLimit record component
    • maxExecutionTime

      public int maxExecutionTime()
      Returns the value of the maxExecutionTime record component.
      Returns:
      the value of the maxExecutionTime record component
    • uploadMaxFilesize

      public int uploadMaxFilesize()
      Returns the value of the uploadMaxFilesize record component.
      Returns:
      the value of the uploadMaxFilesize record component
    • postMaxSize

      public int postMaxSize()
      Returns the value of the postMaxSize record component.
      Returns:
      the value of the postMaxSize record component