Add check for PHP_SAPI

See https://github.com/symfony/symfony/issues/7082#issuecomment-16074887