PHP Error Reporting Production vs Development

后端 未结 2 1962
南方客
南方客 2020-12-10 06:21

What is best practice when setting error reporting on development and production applications? At the moment I have the following:

// development
error_repor         


        
2条回答
  •  醉梦人生
    2020-12-10 06:50

    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.

提交回复
热议问题