NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Environment variables in SRV local web server


Joined: 14 Dec 2006
Posts: 17
Reply with quote
I want to debug some code both locally (using SRV local WEBserver) and remotely (using 3rd party WEB server).

My code uses the PHP getenv function to get the value of an Apache environment variable on the remote server. In order to replicate the behaviour locally, I therefore need to set the equivalent environment variable in the SRV server.

How is this done?

I can't see anything relating to this in the PhpED's SRV settings dialog.

Daniel
View user's profileFind all posts by danielrmSend private message
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
The local SRV is very limited in functionality (basically just enough to allow debugging). I don't think it actually has support for environment variables.
Might I suggest adding a wrapper function around the code that returns the environment variable and in which you detect whether you are running remote or locally? Perhaps you can use $_SERVER [ 'SERVER_ADDR' ] ?
If it's present and set to ip X you're running on apache. If it's set to ip Y it's locally and then you return the value from an array or hardcoded. Assuming the $_SERVER array even contains IPs on SRV Smile
View user's profileFind all posts by BlizzSend private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
SRV server obtains all the environment variables from the system. So if you have a variable set in the system environment variables, you'll see it in the php running under SRV too. (don't forget to exit and re-run SRV after you change the system environment).
After all you can install local Apache and work with it. See NuSphere TechPlatform (free) product.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 14 Dec 2006
Posts: 17
Reply with quote
Thanks for the proposed workaround, Blizz. I actually had a workaround, but want to work with environment variables in my live system, so really want to be able to test and debug using environment variables also.

Dmitri's solution gives me what I need.

Thanks to both of you.

Daniel
View user's profileFind all posts by danielrmSend private message
Environment variables in SRV local web server
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic