Development Workflow

Configure PHP Error Reporting for Local Development

Enable useful PHP diagnostics locally while ensuring errors and stack traces are not exposed to public visitors.

PHP error reporting should help developers diagnose problems without turning the browser into a public diagnostic console. Development and production need different display policies, while both should preserve useful logs.

Enable diagnostics locally

For local development, enable error reporting and display errors in the local PHP configuration. Confirm which php.ini is loaded by the web server and CLI because they may differ. A temporary ini_set() can help isolate a test, but project-wide behavior should be configured consistently.

Log errors as well

Configure an appropriate error log path and ensure the relevant process can write to it. Keep logs outside the public document root, restrict access and rotate them. Do not log passwords, session tokens, API keys or full request bodies by default.

Keep production output safe

Production should not display stack traces or internal file paths to visitors. Log details privately and return a generic error response with a correlation identifier where appropriate. Make sure debug mode cannot be enabled by an untrusted request parameter.

Test both configurations

Verify that a local syntax error produces actionable diagnostics and that the production-like configuration returns a safe response while recording the event. Check PHP-FPM and web-server logs as well as application logs.

Further reading

Share this page Help other developers discover this resource.