1 API Changes between library versions 3 and 4
2 ============================================
7 It is not necessary any more to include the files xmlrpc.inc, xmlrpcs.inc and xmlrpc_wrappers.inc to have the
8 library classes available.
10 Instead, it is recommended to rely on class autoloading.
12 * If you are using Composer, just install the library by declaring it as dependency for your project in composer.json
16 "phpxmlrpc/phpxmlrpc": "~4.0"
19 * If you do not use Composer, an autoloader for the library can be found in src/Atuloader.php.
20 The php example files in the demo/client folder do make use of it.
21 Example code to set up the autoloader:
23 include_once <path to library> . "/src/Autoloader.php";
24 PhpXmlRpc\Autoloader::register();
27 * If you still include manually xmlrpc.inc, xmlrpcs.inc or xmlrpc_wrappers.inc, you will not need to set up
28 class autoloading, as those files do include all the source files for the library classes
34 All classes have ben renamed, are now properly namespaced and follow the CamelCase naming convention.
35 Existing class methods and members have been preserved; all new method names follow camelCase.
39 | Old class | New class |
40 | ------------- | ------------------ |
41 | xmlrpc_client | PhpXmlRpc\Client |
42 | xmlrpc_server | PhpXmlRpc\Server |
43 | xmlrpcmsg | PhpXmlRpc\Request |
44 | xmlrpcresp | PhpXmlRpc\Response |
45 | xmlrpcval | PhpXmlRpc\Value |
48 Global variables cleanup
49 ------------------------
51 All variables in the global scope have been moved into classes.
55 | Old variable | New variable | Notes |
56 | ------------------------ | ------------------------------------------- | --------- |
57 | _xmlrpcs_capabilities | NOT AVAILABLE YET | |
58 | _xmlrpc_debuginfo | PhpXmlRpc\Server::$_xmlrpc_debuginfo | protected |
59 | _xmlrpcs_dmap | NOT AVAILABLE YET | |
60 | _xmlrpcs_occurred_errors | PhpXmlRpc\Server::$_xmlrpcs_occurred_errors | protected |
61 | _xmlrpcs_prev_ehandler | PhpXmlRpc\Server::$_xmlrpcs_prev_ehandler | protected |
62 | xmlrpcWPFObjHolder | PhpXmlRpc\Wrapper::$objHolder | |
66 Global functions cleanup
67 ------------------------
69 Most functions in the global scope have been moved into classes.
71 | Old function | New function |
72 | ------------------------ | ------------------------------------------- |
76 Character sets and encoding
77 ---------------------------
79 The default character set used by the library to deliver data to your app is now UTF8.
80 It is also the character set that the library expects data from your app to be in (including method names).
81 The value can be changed (to either US-ASCII or ISO-8859-1) by setting teh desired value to
82 PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding
84 Usage of closures for wrapping
85 ------------------------------
90 Differences in server behaviour
91 -------------------------------
93 The results for calls to system.listMethods and system.getCapabilities can not be set anymore via changes to
100 * when serialize() is invoked on a response and its payload can not be serialized, an exception is thrown instead of
103 * all error messages now mention the class and method which generated name
105 * all library source code has been moved to the src/ directory
107 * all source code has been reformatted according to modern PSR standards
110 Enabling compatibility with legacy code
111 ---------------------------------------
113 If you have code which relies on version 3 of the phpxmlrpc API, you *should* be able to use version 4 as a drop-in
114 replacement, regardless of all of the changes mentioned above.
116 The magic happens via the xmlrpc.inc, xmlrpcs.inc and xmlrpc_wrappers.inc files, which have been kept solely for
117 the purpose of backwards compatibility (you might notice that they are still in the 'lib' directory, whereas all of
118 the refactored code now sits in the 'src' directory).
120 Of course, some minor changes where inevitable, and backwards compatibility can not be guaranteed at 100%.
121 Below is the list of all known changes and possible pitfalls.
123 ### Default character set used for application data
125 * when including the xmlrpc.inc file, the defalt character set used by the lib to give data to your app gets switched
126 back to ISO-8859-1, as it was in previous versions
128 * if yor app used to change that value, you will need to add one line to your code, to make sure it is properly used
130 // code as was before
131 include('xmlrpc.inc');
132 $GLOBALS['xmlrpc_internalencoding'] = 'UTF-8';
133 // new line needed now
134 PhpXmlRpc\PhpXmlRpc::importGlobals();
136 ### Usage of global variables
138 * ALL global variables which existed after including xmlrpc.inc in version 3 still do exist after including it in v. 4
140 * Code which relies on using (as in 'reading') their value will keep working unchanged
142 * Changing the value of some of those variables does not have any effect anymore on library operation.
146 $GLOBALS['xmlrpcInt']
147 $GLOBALS['xmlrpcBoolean']
148 $GLOBALS['xmlrpcDouble']
149 $GLOBALS['xmlrpcString']
150 $GLOBALS['xmlrpcDatetTme']
151 $GLOBALS['xmlrpcBase64']
152 $GLOBALS['xmlrpcArray']
153 $GLOBALS['xmlrpcStruct']
154 $GLOBALS['xmlrpcValue']
155 $GLOBALS['xmlrpcNull']
156 $GLOBALS['xmlrpcTypes']
157 $GLOBALS['xmlrpc_valid_parents']
158 $GLOBALS['xml_iso88591_Entities']
160 * Changing the value of the other global variables will still have an effect on operation of the library, but only after
161 a call to PhpXmlRpc::importGlobals()
165 // code as was before
166 include('xmlrpc.inc');
167 $GLOBALS['xmlrpc_null_apache_encoding'] = true;
168 // new line needed now
169 PhpXmlRpc\PhpXmlRpc::importGlobals();
171 Alternative solution:
173 include('xmlrpc.inc');
174 PhpXmlRpc\PhpXmlRpc::$xmlrpc_null_apache_encoding = true;
176 * Not all variables which existed after including xmlrpcs.inc in version 3 are available
178 - $GLOBALS['_xmlrpcs_prev_ehandler'] has been replaced with protected static var PhpXmlRpc\Server::$_xmlrpcs_prev_ehandler
179 and is thus not available any more
181 - same for $GLOBALS['_xmlrpcs_occurred_errors']
183 - same for $GLOBALS['_xmlrpc_debuginfo']
185 - $GLOBALS['_xmlrpcs_capabilities'] and $GLOBALS['_xmlrpcs_dmap'] have been removed
187 ### Using typeof/class-name checks in your code
189 * if you are checking the types of returned objects, your checks will most likely fail.
190 This is due to the fact that 'old' classes extend the 'new' versions, but library code that creates object
191 instances will return the new classes.
195 is_a(php_xmlrpc_encode('hello world'), 'xmlrpcval') => false
196 is_a(php_xmlrpc_encode('hello world'), 'PhpXmlRpc\Value') => true
198 ### wrapping methods now return closures
200 might be fixed later?
202 ### server behaviour can not be changed by setting global variables (the ones starting with _xmlrpcs_ )
204 might be fixed later?