Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect and automatically set up php.ini entry for installation #20

Open
asgrim opened this issue Jul 11, 2024 · 1 comment
Open

Detect and automatically set up php.ini entry for installation #20

asgrim opened this issue Jul 11, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request maintainer feedback needed Needs details or feedback to be added by maintainers

Comments

@asgrim
Copy link
Collaborator

asgrim commented Jul 11, 2024

Typically, the approach for adding extension=blah.so or zend_extension=blah.so to the PHP INI would be:

  • add a new file with the line in the directory indicated by Scan for additional .ini files in: using the priority defined in composer.json (e.g. 20-myext.ini)
  • if the Scan for additional .ini files in: is empty, add the line to the file indicated by Loaded Configuration File: entry
  • if that is also empty, tell the user what they need to do

However, when using setups like the deb.sury.org PHP installer, this approach would ONLY enable the ext for a single SAPI (the CLI SAPI). This would be confusing as the extension would not be enabled for the Apache SAPI, so consumers may be confused by the fact it does not have the extension loaded!

Investigate the various common approaches to how php.ini are used, and we may need to add special handling for each "custom" approach, and then fall back to the expected typical approach above.

@Ayesh
Copy link
Member

Ayesh commented Oct 14, 2024

PHP in Debian and derivatives come with a php(en|dis)mod script, that I think solves this problem fairly well. It accepts a SAPI name (all SAPIs by default), and creates a in formats such as 20-mbstring.ini that only has extension=mbstring.so. I like that it does not modify the main php.ini file, but instead adds/removes these "loader" files in all/selected SAPI-specific conf.d folders.

I suppose we can use php_ini_loaded_file()/ PHP_INI_SCAN_DIR/php_ini_scanned_files() to try and guess if we are in a Debian/RHEL-like environment, and if we detect a conf.d in one of the scanned file paths, to add a "loader" ini file for the extension.

On Windows, I don't think PHP_INI_SCAN_DIR is actively used, so in all other situations, we can modify the ini file.

@asgrim asgrim self-assigned this Nov 21, 2024
@asgrim asgrim added the maintainer feedback needed Needs details or feedback to be added by maintainers label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request maintainer feedback needed Needs details or feedback to be added by maintainers
Projects
None yet
Development

No branches or pull requests

2 participants