1. Go to this page and download the library: Download czim/laravel-service library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// Set up defaults
$defaults = new \Czim\Service\Requests\ServiceSoapRequestDefaults();
$defaults->setLocation('http://www.webservicex.net/globalweather.asmx?WSDL')
->setOptions([
'trace' => true,
'exceptions' => true,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
]);
// Instantiate service, with a to-array interpreter
$service = new SoapService(
$defaults,
new \Czim\Service\Interpreters\BasicSoapXmlAsArrayInterpreter()
);
// Prepare a specific request
$request = new ServiceSoapRequest();
$request->setBody([
'CityName' => 'Tokyo',
'CountryName' => 'Japan',
]);
// Perform the call, which will return a ServiceReponse object
$response = $service->call('GetWeather', $request);
// Set up the default and base URI for the service
$defaults = new \Czim\Services\Requests\ServiceRestRequestDefaults();
$defaults->setLocation('http://base.service.url.com/v1');
$defaults->setHttpMethod($service::METHOD_DELETE);
// Instantiate a new service with the defaults
$service = new \Czim\Service\Services\RestService($defaults);
// Perform a call to delete comment 13
$result = $service->call('comments/13');
// Set up the default and base URI for the service
$defaults = new \Czim\Services\Requests\ServiceRestRequestDefaults();
$defaults->setLocation('http://base.service.url.com/v1');
// Instantiate a new service with the defaults
$service = new \Czim\Service\Services\RestService($defaults);
// Create a request object with an HTTP method
$request = new \Czim\Service\Requests\ServiceRestRequest();
$request->setHttpMethod($service::METHOD_DELETE);
// Perform a call to delete comment 13
$result = $service->call('comments/13', $request);
// Decorate a raw XML interpreter with a namespace removal decorator
$interpreter = new \Czim\Service\Interpreters\Decorators\RemoveXmlNamespacesDecorator(
new \Czim\Service\Interpreters\Decorators\BasicRawXmlInterpreter()
);
// Inject the interpreter into a new service
$service = new \Czim\Service\Services\FileService(null, $interpreter);
$services = new \Czim\Service\Collections\ServiceCollection();
// Adding services
$services->put('service name', $service);
// Performing calls on a service
$service->get('service name')
->call('someMethod', [ 'param' => 'value' ]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.