Drupal quick tip of the day: react differently to CLI calls

Sometimes you want to react differently, when the current script is running in a command-line environment. Drupal does this internally e.g. for session handling.

In Drupal 7, there was a dedicated drupal_is_cli() function.

In Drupal 8, this function was removed because you can instead directly check the PHP_SAPI constant:

if (PHP_SAPI === 'cli') {
  // Do stuff


Neuen Kommentar schreiben