use Symfony\Component\HttpFoundation\Request; $request = Request::createFromGlobals(); $scheme = $request->getScheme(); if ($scheme === 'https') { // do something secure } else { // do something non-secure }
use Symfony\Component\HttpFoundation\Request; $request = Request::create('/foo', 'GET', [], [], [], ['HTTPS' => 'on']); $scheme = $request->getScheme(); if ($scheme === 'https') { // do something secure } else { // do something non-secure }This example creates a new `Request` object manually, with a specific URL and an HTTPS header set. The test then checks whether the scheme is HTTPS or not. Both of these examples use the `Symfony\Component\HttpFoundation\Request` class, which is part of the `symfony/http-foundation` package.