Forum Moderators: phranque

Message Too Old, No Replies

metadata as custom environment variables Vs in a database

linux env var's VS PHP env var's VS not having having vars

         

bkode

10:58 am on Sep 28, 2007 (gmt 0)

10+ Year Member



Greetings,

I'm writing a app that relies considerebly on C, cron jobs, and PHP. I'm doing the logic/processing on the server in C, and the interface /website to users is in PHP.

Now i need to maintain some CUSTOM properties that change over time . Basically my app configuration variables or meta data . I have an option to read/write these properties in either c/shell or PHP. Hence the queries cited below in [4 chunks] of thought...

[1] How reliable are environmental variables (for mission critical needs )?
-SO rather than relying on storing in a flat file or in a sql table. i was wondering how reliable/practical is to read/write these metadata in a environmental variable.

[2] If i can use PHP env variables, do i add them to PHP's $_SERVER?
-From a PHP perspective, can i set it somewhere ,and getenv("property") or ini_set i assume.or are there other methods?

[3]If i use OS specific (linux in my case) , how practical/reliable is it to read/write os level env variables.
-i've not drilled into the details of the os level variables. but they shud be there right? or have i missed some major bottleneck?

[4]What are my bottlenecks if use env var's instead of flat files/sql tables for read/writing meta data?
- the first thing that comes to my mind is how to replicate them across servers (i'll have to think about multiple servers in the long run) . Let me remind you that this meta data needs to be consistent and is mission-critical wrt to the logic/processing of my app.

Has anyone dealt with these decisions and with env variables on a consistent basis? any lessons learnt ,any experience / light to share?

Keep Clicking,
Bosky

jtara

6:04 pm on Sep 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



-SO rather than relying on storing in a flat file or in a sql table. i was wondering how reliable/practical is to read/write these metadata in a environmental variable.

Doesn't make sense. You don't store data in environment variables. You pass data in environment variables. Environment variables aren't persistent storage. They are transitory. They exist only as long as the process they are set is running.

bkode

6:14 pm on Sep 28, 2007 (gmt 0)

10+ Year Member



Thanks for clearing out that traditional env variables arn't persistent.
i'm not sure of what they're called . perhaps not env variables.

But do you also mean to say that ,that from a shell access i can't set any custom variable that will be inherent to all process's . sort of like the PATH variables. can't i have a customPATH or customXYZ - either in php or via the os?

Are there no persistent methods or storing/ changing variables that will be inherent to all process's? perhaps evne via php.ini or apache conf or htaccess?

jtara

7:04 pm on Sep 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A new process normally inherits the environment variables of it's parent. But, again, these only live as long as the process.

The PATH variable, etc. only exists because it is set from some script file on system setup. There is no inherent persistence of any environment variables in either Windows or Linux.

Most OS's do have one or more mechanisms for persistent storage of settings, etc. however.

Windows has the Registry (ugh!) and in it's ancient past .ini files. Linux has the .rc file convention. There are plenty of third-party tools for reading/writing/parsing these settings.