简体   繁体   中英

php import remote libraries to run them locally

Being as much direct as I can... does exists a way/tool to share/export PHP libraries remotely available to let them executed locally?

Let me dedetail a little bit better the need that I have:

I'm the web developper/administrator for some subdomains available on my company and each of them shares local data and it's installed and configured on a separate host

http://division-A.company.com    (running on division-A.company.com)
http://division-B.company.com    (running on division-B.company.com)
http://division-Z.company.com    (running on division-C.company.com)

The different host are

  1. configured differently,
  2. shows different information for different pourpouse
  3. but all of them shares the same version of Apache & PHP (5.4.7)

Considering that the 3 different web host are maintained by me... do I have a chance to share with them some common php libraries.

I mean, for example:

Having a function available on [ host-A.company.com ]

webuser@host-A.company.com: /httpdocs/lib/helloworld.php

.

<?php
function HelloWorld() {
     echo "You are on host " $_SERVER['SERVER_NAME'] . "\n";
     return(true);
}
?>

Can (in some way) import it on another host?

webuser@host-B.company.com: /httpdocs/lib/import_remote.php

.

<?php
   include_once("http://division-A.company.com/lib/import_remote.php");
?>

But this approach (and it's more than clear why) does not work properly as the code is executed on remote host and not local one whereas my goal is to have a function that provide me a way to

  • have the function remotely available
  • but run it locally

最简单的方法是将您的库提取到单独的存储库中,并通过作曲家将其作为对所有站点的依赖项包括在内。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM