Skip to content

[PHP] Allow additional php.ini files instead of overwriting via options.file #969

Closed
@ruudk

Description

@ruudk

Currently, there is no way to load additional php.ini files.

When you specify options.file, you override the default loaded php.ini completely.

{
  "applications": {
    "hello-world": {
      "type": "php",
      "root": "/www/public",
      "script": "index.php",
      "options": {
        "file": "some-tweaks.ini"
      }
    }
  }
}

When reading the code, it seems this is how it was designed:

unit/src/nxt_php_sapi.c

Lines 409 to 422 in c905d0d

if (c->options != NULL) {
value = nxt_conf_get_object_member(c->options, &file_str, NULL);
if (value != NULL) {
nxt_conf_get_string(value, &ini_path);
ret = nxt_php_set_ini_path(task, &ini_path,
conf->working_directory);
if (nxt_slow_path(ret != NXT_OK)) {
return NXT_ERROR;
}
}
}

nxt_php_sapi_module.php_ini_path_override = (char *) start;

But, if you want to enable (zend) extensions on a per application basis, this becomes annoying.

You now have to copy the default php.ini, store it in a new file and then append your tweaks to it.

It would be easier if I could do this:

{
  "applications": {
    "hello-world": {
      "type": "php",
      "root": "/www/public",
      "script": "index.php",
      "options": {
        "additional-files": ["some-tweaks.ini"]
      }
    }
  }
}

Or, specify the (additional) extensions that I want to load and let me provide extra config via admin and user:

{
  "applications": {
    "hello-world": {
      "type": "php",
      "root": "/www/public",
      "script": "index.php",
      "options": {
        "extensions": [],
        "zend_extensions": ["xdebug.so"],
        "admin": {
          "xdebug.mode": "debug",
          "xdebug.start_with_request": "trigger",
          "xdebug.client_host": "127.0.0.1",
          "xdebug.idekey": "PHPSTORM"
        }
      }
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    z-documentation-update-neededThis type of issues likely have a link to an issue in the Unit Docs repo

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions