EnvironmentDetectorService
Detects the runtime environment the application is executing under (command-line vs. web server).
EnvironmentDetectorService::detect()
public static function detect(): stringReturns 'cli' when running under the PHP command-line SAPI, otherwise 'web'.