php导入远程库以在本地运行它们

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'] . "
";
     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 simplest way is to extract your library into separate repository, and include it as a dependency to all your sites via composer.