PHP Modules Tutorials - Herong's Tutorial Examples - v5.19, by Herong Yang
Manage Runtime Configuration Directives
This section provides a quick introduction on PHP runtime configuration and how to view/manage configuration directives.
What Is PHP Runtime? - PHP Runtime is a running instance of the PHP environment started by the "php" command.
What Is Runtime Configuration? - Runtime Configuration is a collection of settings, also called directives, used to control the PHP Runtime behavior.
What Is PHP Directive? - PHP Directive is a setting provided as part of the Runtime Configuration.
To view the current settings of PHP runtime configuration, you can:
1. Run "php -i" command - It displays all configuration settings and their values.
2. Call phpinfo() function - It prints all configuration settings and their values to the STDOUT stream.
3. Call ini_get_all() function - It returns all configuration settings and their values as an associative array. It also has an option to return configuration settings for "core" or a given extension name.
To change settings of PHP runtime configuration, you have the following options:
1. Recompile the PHP environment with new settings. For example, run the "./configure" build tool with configuration settings included in the command line: "./configure --mandir=/usr/share/man --enable-mbstring --disable-cgi --with-mysqli=mysqlnd ...". Values specified in the "configure" command are considered as Master Values.
2. Edit the php.ini file - php.ini file is located in system directory and contains configuration settings applied globally on all PHP runtimes. Values specified in the php.ini file are also considered as Master Values.
3. Add/edit an additional .ini file - Additional .ini files are located in system directory and contain additional configuration settings. For example /etc/php.d/etc/php.d/20-mbstring.ini is an additional .ini file for mbstring module. Values specified in an additional .ini file are also considered as Master Values.
4. Edit the .user.ini file - .user.ini file is located in a local directory and contains configuration settings applied only to the PHP runtimes started from a PHP script of the same directory. Values specified in the .user.ini file are considered as Local Values, overriding Master Values.
5. Edit the httpd.conf file - httpd.conf file is located in a Web server and contains configuration settings applied globally to all server side PHP scripts. Values specified in the httpd.conf file are considered as Master Values.
6. Edit the .htaccess file - .htaccess file is located in a document directory of a Web server and contains configuration settings applied only to a PHP script of the same directory. Values specified in an .htaccess file are considered as Local Values, overriding Master Values.
7. Call the set_ini() function - The set_ini() function updates the PHP runtime with the given setting and value. Values specified in set_ini() calls are considered as Local Values, overriding Master Values.
Table of Contents
Introduction and Installation of PHP
Managing PHP Environment and Modules on macOS
Managing PHP Environment and Modules on CentOS
►Manage Runtime Configuration Directives
"php -i" - Display Configuration Information
php.ini - Configuration Directive File
Additional .ini Configuration Files
extension_dir - Module Library Location
"php -m" - Display Loaded Modules
get_extension_funcs() - Get Module Functions
dl() - Load Module Dynamically
DOM Module - Parsing HTML Documents
GD Module - Manipulating Images and Pictures
MySQLi Module - Accessing MySQL Server
OpenSSL Module - Cryptography and SSL/TLS Toolkit
PCRE Module - Perl Compatible Regular Expressions
SOAP Module - Creating and Calling Web Services
SOAP Module - Server Functions and Examples