Options to load DLL in PHP (7.0) at run time?

Viewed 52

I'm building small application to collect data. For data collection PHP is used, for data storage PostgreSQL is used. PostgreSQL is included so I have full control over it. The PHP for collection is triggered by external entity and I have no control over PHP interpreter that will run the code.

Is there a way how to load php_pgsql.dll? at run-time? I know it was asked already, for example here, here and my best source of information was here. If I get it right there is no way if I'm not root of the system (because dl() was removed).

I can add PHP to my application the same way I have added PostgreSQL (to have control over PostgreSQL and do not need to ask someone to install, configure, maintain...), BUT my PHP files are triggered by external application so I have no control over used PHP interpreter/environment.

Is there a way to start from PHP code (let's call it systemPHP) the same PHP code but in different PHP environment (myPHP environment I have control over and where I will have the dll included)?

For example if systemPHP starts collect.php the pseudo code of collect.php will be:

if <this is myPHP> { # How to detect it?
  <execute the data collection code>
}
else {
  <Start collect.php in myPHP transfering all the data to it> # For example if started by apache then also headers, session information etc...
  <Send back result from myPHP via the systemPHP>
}

How to achieve this PHP 'tunnel'?

Thanks for any help or hint. I know that best will be root or at least have intelligent admin, however this is not the case :-(

Currently I'm trying workaround by executing database tasks via shell and then getting response back in PHP, but sometimes it works sometimes not and I believe there is a better way of doing this (not to mention speed and resource usage).

1 Answers

Have you looked into using a messaging queue system? Write to the queue, then have your PHP script running that has php_pgsql.dll already loaded, which checks for new messages in the queue and processes them.

Related