Interpretive File Architectures - PHP & Perl

If you are developing code for interpretive languages such as PHP & Perl, consider the use of the scripts carefully.

As a rule, you should strive to write code which evaluates only the code required for execution. Files should be as small as possible. This is especially important for scripts that run frequently or must be fast.

Key areas to check:

  • Use of ‘library’ files - large files with a collection of unrelated functions that support several types of scripts. These almsot always require the including files to read code that won’t be executed. Better to break them up by related functionality.
  • Common functions should be placed in a single, small, common file. Good components include database connection functions, simple error reporting, and constants.
  • Logging levels should be managed through environment variables. This allows adjustments without modifying code.
  • OOP architectures should probably be avoided for files that require high speed performance.