XRL  latest
Simple XML-RPC Library (both client and server)
fpoirotte\XRL\Server Class Reference

A simple XML-RPC server. More...

+ Inheritance diagram for fpoirotte\XRL\Server:

Public Member Functions

 __construct (\fpoirotte\XRL\EncoderInterface $encoder=null,\fpoirotte\XRL\DecoderInterface $decoder=null)
 
 __get ($func)
 
 __isset ($func)
 
 __set ($func, $callback)
 
 __unset ($func)
 
 call ($procedure, array $params)
 
 count ()
 
 expose ($other, $prefix= '')
 
 getIterator ()
 
 handle ($URI=null)
 
 offsetExists ($func)
 
 offsetGet ($func)
 
 offsetSet ($func, $callback)
 
 offsetUnset ($func)
 

Protected Attributes

 $XRLDecoder
 Decoder for the response.
 
 $XRLEncoder
 Encoder for the request.
 
 $XRLFunctions
 Registered "procedures".
 

Detailed Description

A simple XML-RPC server.

This class uses dynamic properties to manager XML-RPC procedures:

// This registers the procedure "foo" on the XML-RPC server.
// The function "bar" will be called to handle calls to "foo".
$server->foo = 'bar';
// This returns the callable used to handle
// calls to "foo", wrapped in an object
// implementing the "\\fpoirotte\\XRL\\CallableInterface"
// interface.
$foo = $server->foo;
// This tests whether the "foo" procedure
// has been registered on the server.
if (isset($server->foo)) {
...
}
// This unregisters the "foo" procedure
// from the XML-RPC server.
unset($server->foo);

You may also count how many XML-RPC procedures are currently registered on the server:

$nbProcedures = count($server);

Last but not least, you may also iterate over the server's registered XML-RPC procedures:

foreach ($server as $procedure) {
...
}
See also
The code in server.php contains a complete example of a working XML-RPC server which may be queried using the corresponding client (client.php) or XRL's command-line query tool.
Authors
François Poirotte click.nosp@m.y@er.nosp@m.ebot..nosp@m.net

Definition at line 65 of file Server.php.

Constructor & Destructor Documentation

fpoirotte\XRL\Server::__construct ( \fpoirotte\XRL\EncoderInterface  $encoder = null,
\fpoirotte\XRL\DecoderInterface  $decoder = null 
)

Create a new XML-RPC server.

Parameters
fpoirotte::XRL::EncoderInterface$encoder(optional) Encoder to use to build responses. If omitted, an encoder that accepts native PHP types, does not use indentation, but uses the <string> tags is automatically created using the machine's timezone.
fpoirotte::XRL::DecoderInterface$decoder(optional) Decoder to use to parse responses. If omitted, a decoder that performs XML validation and converts values to native PHP types is automatically created using the machine's timezone.
Exceptions
InvalidArgumentExceptionThe given timezone is invalid.

Definition at line 95 of file Server.php.

Member Function Documentation

fpoirotte\XRL\Server::__get (   $func)

Return a procedure previously registered with this XML-RPC server.

Parameters
string$funcThe name of the registered XML-RPC procedure to return.
Return values
mixedThe callable responsible for the XML-RPC procedure registered with the given name, as an object implementing the fpoirotte::XRL::CallableInterface interface, or null if the given name does not refer to an XML-RPC procedure known to this server.
Note
In case the given procedure has not been registered, a PHP notice will be issued.

Definition at line 172 of file Server.php.

fpoirotte\XRL\Server::__isset (   $func)

Test whether a procedure has been registered with the given name on this server.

Parameters
string$funcName of the procedure whose existence must be verified.
Return values
booltrue if the procedure exists, false otherwise.

Definition at line 199 of file Server.php.

fpoirotte\XRL\Server::__set (   $func,
  $callback 
)

Register a new procedure with this XML-RPC server.

Parameters
string$funcA valid name for the procedure. Names starting with the string "XRL" (case-insensitive) are reserved.
mixed$callbackAny valid PHP callback.
Note
See the "Payload format" section at http://xmlrpc.scripting.com/spec.html for information on valid procedure names.
Several syntaxes can be used to refer to a PHP callback, see http://php.net/language.pseudo-types.php#language.types.callback for the full list of supported constructs.

Definition at line 137 of file Server.php.

fpoirotte\XRL\Server::__unset (   $func)

Unregister a procedure.

Parameters
string$funcThe name of the procedure to unregister.
Note
No warning will be emitted if the given procedure has not been registered on this XML-RPC server.

Definition at line 225 of file Server.php.

fpoirotte\XRL\Server::call (   $procedure,
array  $params 
)

Call an XML-RPC procedure.

Parameters
string$procedureName of the procedure to call.
array$paramsParameters for that procedure.
Return values
mixedThe procedure's return value.

Definition at line 385 of file Server.php.

Referenced by fpoirotte\XRL\Server\handle().

fpoirotte\XRL\Server::count ( )

Return the number of XML-RPC procedures currently registered on this server.

Return values
intNumber of currently registered procedures on this server.

Implements Countable.

Definition at line 248 of file Server.php.

fpoirotte\XRL\Server::expose (   $other,
  $prefix = '' 
)

Expose the public methods of a class or object, with an optional prefix.

Parameters
mixed$otherClass or object to expose. For classes, only public static methods are exposed. For objects, public non-static methods are exposed, except for the constructor.
string$prefixPrefix under which the class/object's methods will be exposed. Defaults to the empty string (ie. the methods are exposed without any prefix).
Returns
This method does not return any value.
Note
To expose all public methods of an object (both static and non-static), call this method twice:
  • once with the actual object
  • and a second time with get_class($object)

Definition at line 290 of file Server.php.

fpoirotte\XRL\Server::getIterator ( )

Get an iterator over this server's registered XML-RPC procedures.

Return values
ArrayIteratorAn iterator over this server's registered procedures.

Implements IteratorAggregate.

Definition at line 261 of file Server.php.

fpoirotte\XRL\Server::handle (   $URI = null)

Handle an XML-RPC request and return a response for it.

Parameters
string$URI(optional) URI to the XML-RPC request to process, If omitted, this method will try to retrieve the request directly from the data POST'ed to this script.
Return values
fpoirotte::XRL::ResponseInterfaceThe response for that request. This response may indicate either success or failure of the Remote Procedure Call.
Note
Use the "data://" wrapper to pass the serialized request as raw data.
See also
See http://php.net/wrappers.data.php for information on how to use the "data://" wrapper.

Definition at line 352 of file Server.php.

References fpoirotte\XRL\Server\call().

fpoirotte\XRL\Server::offsetExists (   $func)

Test whether a procedure has been registered with the given name on this server.

Parameters
string$funcName of the procedure whose existence must be verified.
Return values
booltrue if the procedure exists, false otherwise.

This method is an alias for fpoirotte::XRL::Server::__isset().

Implements ArrayAccess.

Definition at line 209 of file Server.php.

fpoirotte\XRL\Server::offsetGet (   $func)

Return a procedure previously registered with this XML-RPC server.

Parameters
string$funcThe name of the registered XML-RPC procedure to return.
Return values
mixedThe callable responsible for the XML-RPC procedure registered with the given name, as an object implementing the fpoirotte::XRL::CallableInterface interface, or null if the given name does not refer to an XML-RPC procedure known to this server.
Note
In case the given procedure has not been registered, a PHP notice will be issued.

This method is an alias for fpoirotte::XRL::Server::__get().

Implements ArrayAccess.

Definition at line 182 of file Server.php.

fpoirotte\XRL\Server::offsetSet (   $func,
  $callback 
)

Register a new procedure with this XML-RPC server.

Parameters
string$funcA valid name for the procedure. Names starting with the string "XRL" (case-insensitive) are reserved.
mixed$callbackAny valid PHP callback.
Note
See the "Payload format" section at http://xmlrpc.scripting.com/spec.html for information on valid procedure names.
Several syntaxes can be used to refer to a PHP callback, see http://php.net/language.pseudo-types.php#language.types.callback for the full list of supported constructs.

This method is an alias for fpoirotte::XRL::Server::__set().

Implements ArrayAccess.

Definition at line 147 of file Server.php.

fpoirotte\XRL\Server::offsetUnset (   $func)

Unregister a procedure.

Parameters
string$funcThe name of the procedure to unregister.
Note
No warning will be emitted if the given procedure has not been registered on this XML-RPC server.

This method is an alias for fpoirotte::XRL::Server::__unset().

Implements ArrayAccess.

Definition at line 235 of file Server.php.


The documentation for this class was generated from the following file: