Running php when server starts

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
AluminX
Forum Newbie
Posts: 19
Joined: Sat Jul 17, 2004 9:53 am

Running php when server starts

Post by AluminX »

Hi, Not sure if this question belongs here...
I have Apache 2.2 and php5 setup localy. I would like to run a certain php function as soon as apache starts.
The function should call in a schema.xml(parse it) and keep it in the memory so that everytime the client makes a call to access the db, the server has the table structure in the memory for fast access.
However i don't know how to initiate such a function as well as how to keep it in the memory.
If anyone can help would be greatly appreciated

Thank you
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: Running php when server starts

Post by php_east »

maybe you can use this, from PHP5 manual....
auto_prepend_file string
Specifies the name of a file that is automatically parsed before the main file. The file is included as if it was called with the include() function, so include_path is used.
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Running php when server starts

Post by Mark Baker »

For keeping a persistent structure in memory, take a look at PHP's APC module or memcache.
How to execute a script on server startup? Only way I know is manually, though I suppose it would be possible to execute a cron job that does a wget against a server script, which tests to see if the structure is cached, and if nort reads and caches it
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: Running php when server starts

Post by php_east »

AluminX wrote:The function should call in a schema.xml(parse it) and keep it in the memory so that everytime the client makes a call to access the db, the server has the table structure in the memory for fast access.
isn't this the db/mysql function though ? if the db is started/connected upon php start, that would already put the db in a ready state, no ?
AluminX
Forum Newbie
Posts: 19
Joined: Sat Jul 17, 2004 9:53 am

Re: Running php when server starts

Post by AluminX »

Mark Baker wrote:For keeping a persistent structure in memory, take a look at PHP's APC module or memcache.
How to execute a script on server startup? Only way I know is manually, though I suppose it would be possible to execute a cron job that does a wget against a server script, which tests to see if the structure is cached, and if nort reads and caches it
Thanks, i think this is what i actually need.
That's what i'm looking for, how to create a persistent data model.
I'm familiar with the concept but not with the implementation.

Thanks anyway, that should keep me busy until i figure it out :)
Post Reply