Php.Ini Production VS Development

Php.ini production vs development

First, make sure you're editing php.ini, not php-development.ini or php-production.ini or anything BUT php.ini. After that, ensure you restart your Apache server or your changes won't take effect.

Also, check out ini_set for setting ini values at runtime.

How is php.ini related to php.ini-development and php.ini-production?

They are template files for you to copy over to your actual php.ini if you feel it matches your environment's needs.

  • Development environment offers verbose messages and comfortable optional features, what you want when you're coding your scripts.
  • Production environment is typically more minimalist (i.e. errors are logged rather than displayed, etc), for interacting with real users efficiently.

PHP Error Reporting Production vs Development

Quoting the php-production.ini that should have come bundled with your PHP:

; PHP comes packaged with two INI files. One that is recommended to be used
; in production environments and one that is recommended to be used in
; development environments.

; php.ini-production contains settings which hold security, performance and
; best practices at its core. But please be aware, these settings may break
; compatibility with older or less security conscience applications. We
; recommending using the production ini in production and testing environments.

and further

; display_errors
; Default Value: On
; Development Value: On
; Production Value: Off

; display_startup_errors
; Default Value: Off
; Development Value: On
; Production Value: Off

; error_reporting
; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
; Development Value: E_ALL
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT

; html_errors
; Default Value: On
; Development Value: On
; Production value: On

; log_errors
; Default Value: Off
; Development Value: On
; Production Value: On

Since you asked for best practise, I suggest you go with that.

Using php.ini-production and php.ini-development - php.ini breaks Kubernetes env vars

Seems like switch from fetching environmental variables with $_ENV['<varname>'] to getenv('<varname>') fixed the issue.

php.ini file nowhere to be found?

Where PHP is installed C:\php there is a php.ini-development and php.ini-production. You can copy or rename one of these to php.ini. These are templates and have all of the default settings that are needed. The main difference is that the development one will have error reporting turned on and the production one will not:

It should be loaded from either the PHP directory C:\php or C:\windows. I use the PHP directory as PHP I believe, will always look in the directory from which PHP is run:

copy c:\php\php.ini-development c:\php\php.ini

Or:

copy c:\php\php.ini-development c:\windows\php.ini

My system:

Configuration File (php.ini) Path       C:\Windows
Loaded Configuration File C:\app\php\php.ini


Related Topics



Leave a reply



Submit