Writing Modern PHP Print

  • programminglanguages, programming, php, database, caching, troubleshooting, guide, howto
  • 0

Current practice.

WHAT TO DECLARE

Strict types, at the top of every file.

WHY

Otherwise values are converted automatically, which hides errors.

WHAT TO USE

Type declarations on parameters, returns and properties Constructor property promotion Enumerations, for fixed sets of values Named arguments, for clarity Null-safe access

WHAT TO USE FOR DEPENDENCIES

The standard dependency manager, with the lock file committed.

WHAT TO FOLLOW

The community coding standards, applied by a tool.

WHAT TO NEVER DO

Build queries by joining strings Output values without escaping Suppress errors with the suppression operator Use functions long deprecated

WHAT TO USE FOR DATABASE ACCESS

Prepared statements, always.

WHAT TO CONFIGURE IN PRODUCTION

Errors logged, never displayed Current version Caching of compiled code enabled

WHAT TO TEST WITH

The standard testing framework.

WHAT TO CHECK

Which version your hosting runs, which may differ from the command-line version.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot