Yeah, it looks like that.
I had the same error and was hoping I could just set that value locally with .user.ini
to have the error shut up, but apparently zend.assertions
is one of those flags that can’t be set on the per-directory level. So I had to configure it on the PHP-FPM level indeed just so I could move on. Maybe there’s a better way though.
For those coming from Google and willing to read more, here’s what ChatGPT had to say about it.
If settings like expose_php
, zend.assertions
, and previously mentioned display_errors
in the .user.ini
file don’t seem to have any effect, it could be due to the nature of these directives and how PHP-FPM processes .user.ini
files.
Directive Scope and PHP-FPM
Some PHP directives cannot be changed using .user.ini
files due to their scope. PHP directives are classified into different modes, indicating where they can be changed:
- PHP_INI_USER: Can be set in user scripts,
.htaccess
, or .user.ini
- PHP_INI_PERDIR: Can be set in
.htaccess
or .user.ini
- PHP_INI_SYSTEM: Can only be set in
php.ini
or the server configuration file
- PHP_INI_ALL: Can be set anywhere
expose_php
and zend.assertions
are examples of directives that have a PHP_INI_SYSTEM scope, meaning they can only be set in the php.ini
file or through the server’s (or PHP-FPM’s) startup configuration. This is why changes to these directives in a .user.ini
file do not take effect.
Understanding .user.ini
Limitations
.user.ini
files are very useful for overriding certain PHP settings on a per-directory basis when using PHP as CGI/FastCGI, such as with PHP-FPM. However, they have limitations:
- Scope: Only directives that are flagged as PHP_INI_ALL or PHP_INI_PERDIR can be overridden in
.user.ini
.
- Directive Nature: Some directives are intended to be set before PHP starts (system-level), and thus cannot be altered at runtime or through per-directory configurations.
Solutions and Workarounds
Given these limitations, if you need to change directives like expose_php
or zend.assertions
, you have to modify them in the php.ini
file or, depending on your hosting environment, through a custom PHP configuration provided by your hosting service.
- For
php.ini
: Edit your php.ini
file directly to change these settings. Remember to restart your PHP-FPM service to apply these changes.
- PHP-FPM Pool Configuration: For settings that affect PHP-FPM behavior or performance but are not changeable through
.user.ini
, consider editing the PHP-FPM pool configuration files directly (typically found in /etc/php/7.x/fpm/pool.d/
or a similar directory). Again, restart PHP-FPM after making changes.
Verifying Changes
To verify changes made directly to php.ini
or PHP-FPM’s pool configuration files:
- Use
phpinfo()
in a PHP script to output current configuration settings and verify that your changes have taken effect.
- Ensure you’re editing the correct
php.ini
file or pool configuration file used by your PHP-FPM service, as there can be multiple versions of PHP installed on a server.
In conclusion, understanding the scope and limitations of PHP configuration directives is crucial for effective PHP configuration management, especially when working with PHP-FPM and .user.ini
files. For system-level directives, modifications must be made directly within the php.ini
file or through server-level configurations.