Spoof $ _SERVER ['HTTPS'] on the local Wamp server for testing

Is it possible to configure local configuration (Wampserver works) so that my PHP application considers that HTTPS is enabled locally? The application requires HTTPS (by checking $_SERVER['HTTPS']) before doing anything, but I do not want you to encounter the problem of fully configuring HTTPS locally. Thank.

Edit: I have to mention that this is not the application that I wrote, only the one that I am charged with supporting. This check is performed in many places (50-100) around the server.

+3
source share
3 answers

You can mock this variable in the initialization file by adding:

$_SERVER['HTTPS'] = true;
+2
source

. , , , . , , .

$_SERVER['HTTPS'] = true;
+2

Move check to object

   class Request
   {
       function isHttps()
       {
            // check for local site here,
            // or better still, use a DevRequest class or a Mock to pass
            // your local requirements
       }

   }

and then use

if($request->isHttps()) {...} 
0
source

All Articles