Run a PHP branch that still receives security fixes and plan upgrades before it reaches end of life. Keep Composer dependencies under review, remove packages that are no longer needed and apply security updates through a controlled release process. A supported runtime cannot protect an application from an outdated library, so both layers need attention.
Use secure production configurationDisable detailed error output and debugging on public systems, keep secrets outside the web root and restrict file permissions to what the application actually needs. Review PHP settings for uploads, sessions, remote file access and dangerous execution paths. Configuration should be managed consistently across staging and production, with sensitive values supplied through protected environment or secret-management controls.
Validate input and encode outputTreat every request value, file name, cookie and API response as untrusted until it has been checked for the expected type, length and format. Use parameterised database queries, allow lists where possible and context-appropriate output encoding. Validation reduces unexpected data; encoding helps stop untrusted content becoming executable markup or script in a user's browser.
Protect authentication and sessionsUse strong password hashing, secure cookies, HTTPS, sensible session expiration and protections against cross-site request forgery. Apply multifactor authentication to administrative access where the application supports it, limit login attempts and avoid exposing whether a username exists. Keep administrator accounts separate from everyday user accounts and review privileged access regularly.
Treat uploads and file access as high riskStore user uploads outside the public web root when possible, verify file type and size on the server, generate safe storage names and prevent uploaded content from being executed as code. Do not build file paths directly from user input. Review image processing, document previews and archive extraction because these features can introduce additional libraries and attack paths.
Monitor, test and prepare to recoverLog security-relevant events without writing passwords, tokens or unnecessary personal data into logs. Monitor failed logins, unexpected administrative changes and repeated application errors. Test backups and restoration, scan dependencies, review access after changes and maintain a clear process for applying urgent fixes. Security is an operating practice that continues after a site is launched.
For technical reference, review the PHP supported versions page and the OWASP PHP Configuration Cheat Sheet.
Talk to ViewertechFor practical PHP hosting, application security and maintenance guidance tailored to your organisation, contact the Viewertech team.
