Pages

Tuesday, March 25, 2014

Runtime Configuration

The configuration file 

The configuration file (php.ini) is read when HHVM starts up. For the server module versions of HHVM, this happens only once when the web server is started. For the CLI (Command-Line) versions, it happens on every invocation.
php.ini is searched for in these locations (in order):
  • /etc/hhvm/php.ini
Note:
Use the -c option to HHVM to specify a custom location for the HHVM php.ini file.
Using environment variables can be used in php.ini as shown below.
Example #1 php.ini Environment Variables
; PHP_MEMORY_LIMIT is taken from environment
memory_limit = ${PHP_MEMORY_LIMIT}
The php.ini directives handled by extensions are documented on the respective pages of the extensions themselves. A list of the core directives is available in the appendix. Not all HHVM directives are necessarily documented in this manual: for a complete list of directives available in your HHVM version, please read your well commented php.ini file.
Example #2 php.ini example
; any text on a line after an unquoted semicolon (;) is ignored
[php] ; section markers (text within square brackets) are also ignored
; Boolean values can be set to either:
;    true, on, yes
; or false, off, no, none
register_globals = off
track_errors = yes

; you can enclose strings in double-quotes
include_path = ".:/usr/local/lib/hhvm"

; backslashes are treated the same as any other character
include_path = ".;c:\hhvm\lib"

Where a configuration setting may be set 

These modes determine when and where a HHVM directive may or may not be set, and each directive within the manual refers to one of these modes. For example, some settings may be set within a PHP script using ini_set(), whereas others may require php.ini.
For example, the output_buffering setting is PHP_INI_PERDIR therefore it may not be set using ini_set(). However, thedisplay_errors directive is PHP_INI_ALL therefore it may be set anywhere, including with ini_set().
Definition of PHP_INI_* modes
ModeMeaning
PHP_INI_USEREntry can be set in user scripts (like with ini_set()).
PHP_INI_PERDIREntry can be set in php.ini, .htaccess, httpd.conf or .user.ini (since PHP 5.3)
PHP_INI_SYSTEMEntry can be set in php.ini
PHP_INI_ALLEntry can be set anywhere

How to change configuration settings 

Other interfaces to HHVM 

Regardless of how you run HHVM, you can change certain values at runtime of your scripts through ini_set(). See the documentation on the ini_set() page for more information.
If you are interested in a complete list of configuration settings on your system with their current values, you can execute the phpinfo() function, and review the resulting page. You can also access the values of individual configuration directives at runtime using ini_get() or get_cfg_var().

No comments:

Post a Comment