I have a class in a server1. FILE1 in server1
<?php
class myObject
{
public function __construct()
{
echo 'Hello, World';
}
}
?>
FILE 2 in server2
$section = require('http://xx.xxx.xxx.x/plugins/myObject.php');
$intance = new myObject();
When file2 is called from a php file in server1 itself, Object is created. I can see 'Hello World' in browser. But it fails when file2 is called from server2. I get fatal error class not found. I have tried include/file_get_contents/read/ __autoload /spl_autoload_register methods also. Nothing helps to invoke my class from another server.
Is this possible? Can anyone please suggest an alternative? Please help
UPDATE: i have fopen and include url on in server2 from where iam trying to include file. Actually I needed the class and my website to be two servers.
SCENARIO: I am tring to build a wallet website in server2. I have necessary plugins in another server [s1]. I have written a class file interacting with plugins in server 1 itself. Iam planning to have wallet websites in more servers. but all of these websites will interact with class in server1. If I could somehow get the code in that class to my website, then i could create objects and call class methods from other servers also. Please suggest other way to implement this.
UPDATE 2: Can I build somthing like API where all my websites will send request to main class in S1 and get get response. An example would be helpful