|
| 1 | +XMLRPC for PHP |
| 2 | +============== |
| 3 | + |
| 4 | +Requirements |
| 5 | +------------ |
| 6 | + |
| 7 | +The following requirements should be met prior to using 'XMLRPC for PHP': |
| 8 | + |
| 9 | +* PHP 5.3.0 or later |
| 10 | + |
| 11 | +* the php "curl" extension is needed if you wish to use SSL or HTTP 1.1 to |
| 12 | + communicate with remote servers |
| 13 | + |
| 14 | +The php "xmlrpc" native extension is not required, but if it is installed, |
| 15 | +there will be no interference with the operation of this library. |
| 16 | + |
| 17 | + |
| 18 | +Installation instructions |
| 19 | +------------------------- |
| 20 | + |
| 21 | +Installation of the library is quite easy: |
| 22 | + |
| 23 | +1. Via Composer (highly recommended): |
| 24 | + |
| 25 | + 1. Install composer if you don't have it already present on your system. |
| 26 | + Depending on how you install, you may end up with a composer.phar file in your directory. |
| 27 | + In that case, no worries! Just substitute 'php composer.phar' for 'composer' in the commands below. |
| 28 | + |
| 29 | + 2. If you're creating a new project, create a new empty directory for it. |
| 30 | + |
| 31 | + 3. Open a terminal and use Composer to grab the library. |
| 32 | + |
| 33 | + $ composer require phpxmlrpc/phpxmlrpc:4.0 |
| 34 | + |
| 35 | + 4. Write your code. |
| 36 | + Once Composer has downloaded the component(s), all you need to do is include the vendor/autoload.php file that |
| 37 | + was generated by Composer. This file takes care of autoloading all of the libraries so that you can use them |
| 38 | + immediately, including phpxmlrpc: |
| 39 | + |
| 40 | + // File example: src/script.php |
| 41 | + |
| 42 | + // update this to the path to the "vendor/" directory, relative to this file |
| 43 | + require_once __DIR__.'/../vendor/autoload.php'; |
| 44 | + |
| 45 | + use PhpXmlRpc\Value; |
| 46 | + use PhpXmlRpc\Request; |
| 47 | + use PhpXmlRpc\Client; |
| 48 | + |
| 49 | + $client = new Client('http://some/server'); |
| 50 | + $response = $client->send(new Request('method', array(new Value('parameter')))); |
| 51 | + |
| 52 | + 5. IMPORTANT! Make sure that the vendor/phpxmlrpc directory is not directly accessible from the internet, |
| 53 | + as leaving it open to access means that any visitor can trigger execution of php code such as |
| 54 | + the built-in debugger. |
| 55 | + |
| 56 | + |
| 57 | +2. Via manual download and autoload configuration |
| 58 | + |
| 59 | + 1. copy the contents of the src/ folder to any location required by your |
| 60 | + application (it can be inside the web server root or not). |
| 61 | + |
| 62 | + 2. configure your app autoloading mechanism so that all classes in the PhpXmlRpc namespace are loaded |
| 63 | + from that location: any PSR-4 compliant autoloader can do that, if you don't have any there is one |
| 64 | + available in src/Autoloader.php |
| 65 | + |
| 66 | + 3. Write your code. |
| 67 | + |
| 68 | + // File example: script.php |
| 69 | + |
| 70 | + require_once __DIR__.'my_autoloader.php'; |
| 71 | + |
| 72 | + use PhpXmlRpc\Value; |
| 73 | + use PhpXmlRpc\Request; |
| 74 | + use PhpXmlRpc\Client; |
| 75 | + |
| 76 | + $client = new Client('http://some/server'); |
| 77 | + $response = $client->send(new Request('method', array(new Value('parameter')))); |
| 78 | + |
| 79 | + 5. IMPORTANT! Make sure that the vendor/phpxmlrpc directory is not directly accessible from the internet, |
| 80 | + as leaving it open to access means that any visitor can trigger execution of php code such as |
| 81 | + the built-in debugger. |
| 82 | + |
| 83 | +Tips |
| 84 | +---- |
| 85 | + |
| 86 | +Please note that usage of the 'pake' command is not required for installation of the library. |
| 87 | +At this moment it is only useful to build the html and pdf versions of the documentation, and the tarballs |
| 88 | +for distribution of the library. |
0 commit comments