Thursday, January 27, 2005

PHP: PEAR and PEAR::SOAP instalation. Quick start

Install PEAR

Download file go-pear.php from http://go-pear.org/ and placed in php installation directory, example c:\wamp\php

Open command line editor and type

C:\wamp\php>php go-pear.php

After PEAR installed then type

C:\wamp\php>pear install Mail_Mime HTTP_Request Net_URL Net_DIME SOAP

If you are behind the firewall then you will get

Warning: fsockopen(): unable to connect to pear.php.net:80 (Unknown error) in RP
C.php on line 464
XML_RPC_Client: Connection to RPC server pear.php.net failed

It happened because you haven't set your proxy. You can see your PEAR configuration by typing

C:\wamp\php>pear config-show
CONFIGURATION:
==============
PEAR executables directory bin_dir C:\wamp\php
PEAR documentation directory doc_dir C:\wamp\php\pear\docs
PHP extension directory ext_dir C:\php5
PEAR directory php_dir C:\wamp\php\pear
PEAR Installer cache directory cache_dir C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\pear\cache
PEAR data directory data_dir C:\wamp\php\pear\data
PHP CLI/CGI binary php_bin c:\wamp\php\php.exe
PEAR test directory test_dir C:\wamp\php\pear\tests
Cache TimeToLive cache_ttl 3600
Preferred Package State preferred_state stable
Unix file mask umask 0
Debug Log Level verbose 1
HTTP Proxy Server Address http_proxy
PEAR server master_server pear.php.net
PEAR password (for password
maintainers)
Signature Handling Program sig_bin c:\gnupg\gpg.exe
Signature Key Directory sig_keydir C:\WINNT\pearkeys
Signature Key Id sig_keyid
Package Signature Type sig_type gpg
PEAR username (for username
maintainers)

Set http_proxy varible configuration :

C:\wamp\php>pear config-set http_proxy http://3.193.197.2:8080

After that try to install required and SOAP package again

C:\wamp\php>pear install Mail_Mime HTTP_Request Net_URL Net_DIME SOAP
downloading Net_URL-1.0.14.tgz ...
Starting to download Net_URL-1.0.14.tgz (5,173 bytes)
.....done: 5,173 bytes
No release with state equal to: 'stable' found for 'SOAP'

The SOAP package is not stable yet. You need to set your prefered
package state to beta if you want to use this package.

C:\wamp\php>pear config-set preferred_state beta

C:\wamp\php>pear install Mail_Mime HTTP_Request Net_URL Net_DIME SOAP
downloading Mail_Mime-1.2.1.tgz ...
Starting to download Mail_Mime-1.2.1.tgz (15,268 bytes)
.....done: 15,268 bytes
downloading HTTP_Request-1.2.4.tgz ...
Starting to download HTTP_Request-1.2.4.tgz (13,212 bytes)
...done: 13,212 bytes
downloading Net_URL-1.0.14.tgz ...
Starting to download Net_URL-1.0.14.tgz (5,173 bytes)
...done: 5,173 bytes
downloading Net_DIME-0.3.tgz ...
Starting to download Net_DIME-0.3.tgz (6,740 bytes)
...done: 6,740 bytes
downloading SOAP-0.8.1.tgz ...
Starting to download SOAP-0.8.1.tgz (69,177 bytes)
...done: 69,177 bytes
install ok: Net_DIME 0.3
install ok: Mail_Mime 1.2.1
install ok: Net_URL 1.0.14
install ok: HTTP_Request 1.2.4
install ok: SOAP 0.8.1


After PEAR::SOAP installed sucessfuly, try to use PEAR::SOAP library for web service client

<?
require_once 'SOAP/Client.php';
$wsdl_url = 'http://soap.amazon.com/schemas3/AmazonWebServices.wsdl';
$proxyParams = array('proxy_host' => '3.193.12.2','proxy_port' => 8080);
$WSDL = new SOAP_WSDL($wsdl_url);
$client = $WSDL->getProxy();
$params = array(
'manufacturer' => "O'Reilly",
'mode' => 'books',
'sort' => '+title',
'page' => 1,
'type' => 'lite',
'tag' => 'trachtenberg-20',
'devtag' => 'XXXXXXXXXXXXXX',
);
$books = $client->ManufacturerSearchRequest($params);
?>


Some Links/Tutorial on PEAR::SOAP implemantation :
A PHP Web Services Client
PEAR::SOAP Server Quick Start
PEAR::SOAP Client Fast Start

No comments:

Followers