#1774

[Feature]: Set php.ini values for generated PHP builds

Opensudaneseopened 20d ago

Existing issue

  • I have searched the existing issues and found no duplicate.

Problem or use case

Generated PHP builds run with PHP's built-in defaults. Openship offers no setting to change them. References are at 8cddb2675.

  • The runtime stage writes no php.ini and sets no PHP directives (packages/adapters/src/runtime/docker-recipes/php.ts:127-173).
  • The FrankenPHP images ship no php.ini (https://frankenphp.dev/docs/config/, "Docker" section).
  • The built-in defaults are upload_max_filesize=2M, post_max_size=8M and memory_limit=128M (php-src main/main.c).
  • The edge accepts request bodies up to 50 MB by default (packages/adapters/src/infra/openresty-lua.ts:100).

So an upload between 2 MB and 50 MB passes the edge and then fails inside PHP. PHP does not let application code raise the two upload limits with ini_set(). A global memory_limit for workers and release commands has the same gap. openship.json has no field for PHP settings.

Proposed solution

Two possible shapes:

  1. A phpIni map in openship.json and the build settings, from directive name to value:

    { "phpIni": { "upload_max_filesize": "25M", "post_max_size": "30M", "memory_limit": "512M" } }

    The recipe writes it to $PHP_INI_DIR/conf.d/zz-openship.ini in the runtime stage. Web, role and release containers then share the same settings. Validation can reject keys that do not match ^[a-z0-9_.]+$ and values that contain line breaks or quotes.

  2. An ini file in the image that reads environment variables. PHP expands ${VAR} in ini files. The recipe could ship lines such as upload_max_filesize = ${PHP_UPLOAD_MAX_FILESIZE} and set defaults with ENV in the image. Projects then change the values through their environment, without a rebuild and without a new project field. The serversideup/php images use this pattern, with slightly different variable names.

A possible follow-up: derive upload_max_filesize and post_max_size from the project's clientMaxBodySize (#100), or from the 50m edge default when it is unset. Per-domain caps (#1431) would need a rule for which value applies.

If you prefer no new PHP-specific setting, two smaller changes would cover the upload case. The recipe could match PHP's upload limits to the edge limit. Or the docs could describe PHP_INI_SCAN_DIR as the supported route.

Alternatives considered

  • FRANKENPHP_CONFIG with php_ini lines. The bundled Caddyfile reads it, but it applies to the web server only, not to CLI workers or release commands. Openship does not document it as a setting.
  • PHP_INI_SCAN_DIR set to a value such as :/app/docker/php, a directory of .ini files in the repository. The leading colon keeps the image's conf.d, which loads the PHP extensions. This covers every process, but each application must carry and remember the files.
  • A runtime install step (#1773) could also write such a file, but a typed setting is easier to validate.
  • A custom runtimeImage that ships its own php.ini. This needs a maintained base image.

I have not tested FRANKENPHP_CONFIG or PHP_INI_SCAN_DIR on Openship.

Additional context

My case is a Laravel 13 application that accepts attachments of up to 25 MB.

Activity

0

No activity yet.