I am mostly looking for Apache Thrift, but in order to talk between JavaScript over Ajax and PHP. I know that Thirft generates both, but as far as I know, JavaScript code should speak through JSONProtocol, which the protocol has not written about in PHP yet.
Can other alternatives be offered?
If you are not familiar with Thrift, this is a simple (ish) definition of what I need:
Consider this as a common interface definition language (IDL), where I configure a User object, an AuthenticationResult result object, and a method called UserCommands.Authenticate ();
struct User {
1: number id,
2: string firstName,
3: string lastName
}
struct AuthenticationResult {
1: number currentTime,
2: User user
}
service UserCommands {
AuthenticationResult Authenticate(1:string username, 2:string password)
}
I am running a program or something else, it creates JS and PHP libraries based on the above.
Then in JS I could call (with a useful type).
var myAuthResult = UserCommands.Authenticate('myUser', 'myPass');
alert ("My first name is : " + myAuthResult.user.firstName);
PHP UserCommands :
function Authenticate($username, $password) {
$myUser = new User();
$myUser->firstName = "Fred";
$myUser->lastName = "Thompson";
$myAuthResult = new AuthenticationResult ();
$myAuthResult->currentTime = date("U");
$myAuthResult->user = $myUser;
return $myAuthResult;
}
, PHP , JS .
out, .
!