noiselabs/nusoap-bundle
Integrates the NuSOAP PHP toolkit with Symfony, providing a convenient way to build and consume SOAP web services inside Symfony applications. The bundle wires NuSOAP into the framework so SOAP endpoints and clients can be defined and configured with minimal boilerplate.
This package is a Symfony2 bundle, not a Laravel package. It is a thin integration layer that registers NuSOAP classes/services inside a Symfony2 container. For a Laravel codebase, do not install noiselabs/nusoap-bundle; use the underlying NuSOAP library directly and copy the bundle’s service-wiring ideas into a Laravel service provider.
Minimal path:
composer require nusoap/nusoap. If the library is not PSR-4 autoloadable, place it under app/Support/NuSOAP and add a classmap entry in composer.json.app/Services rather than calling new \nusoap_client(...) from controllers.AppServiceProvider or use Laravel’s container auto-resolution.php artisan tinker or a throwaway Artisan command before wiring it into HTTP flows.Where to look first in the repository:
README.md for the intended Symfony registration/configuration.DependencyInjection/ for the extension class and configuration tree.Resources/config/services.* for the service definition the bundle exposes.First realistic use case: consuming a legacy SOAP/WSDL service from a Laravel controller or queued job. A minimal wrapper looks like:
namespace App\Services;
class LegacySoapClient
{
protected \nusoap_client $client;
public function __construct(array $config)
{
$this->client = new \nusoap_client($config['wsdl'], true);
$this->client->setCredentials($config['username'], $config['password']);
$this->client->timeout = $config['timeout'] ?? 30;
$this->client->response_timeout = $config['response_timeout'] ?? 30;
$this->client->soap_defencoding = 'UTF-8';
if ($error = $this->client->getError()) {
throw new \RuntimeException('NuSOAP init failed: '.$error);
}
}
public function call(string $operation, array $params = [])
{
$result = $this->client->call($operation, $params);
if ($this->client->fault) {
throw new \RuntimeException('SOAP fault: '.json_encode($result));
}
if ($error = $this->client->getError()) {
throw new \RuntimeException('SOAP error: '.$error);
}
return $result;
}
}
Wrap NuSOAP behind an application service. The bundle’s main value is container integration; in Laravel, your wrapper is the integration point. Inject LegacySoapClient into controllers, actions, and jobs instead of instantiating NuSOAP everywhere.
Centralize configuration. Keep WSDL URL, credentials, timeouts, and encoding in config/services.php or a dedicated config/legacy-soap.php, sourced from .env. Avoid scattering endpoint strings across the codebase.
Support multiple named clients. If you integrate more than one legacy SOAP service, build a small factory:
class SoapClientFactory
{
public function __construct(private array $configs) {}
public function client(string $name): LegacySoapClient
{
return new LegacySoapClient($this->configs[$name]);
}
}
Bind the factory as a singleton and resolve clients by name.
Use queued jobs for unreliable endpoints. SOAP services are often slow or flaky. Put calls in jobs with explicit $tries, $backoff, and retry_after values. This gives you retries and isolation from request timeouts.
Normalize errors at the boundary. NuSOAP generally returns errors rather than throwing. Convert fault, getError(), and malformed responses into domain exceptions so controllers and jobs do not branch on NuSOAP internals.
Log request/response around the call. NuSOAP exposes request, response, and debug_str properties. Log them at debug level in non-production and redact credentials or sensitive payload fields.
Use WSDL mode unless you must not. Pass true as the second constructor argument when you have a WSDL. For non-WSDL mode, you must supply the endpoint, namespace, SOAP action, and often explicit complex-type definitions — more brittle and more code.
Testing pattern. Define a SoapClientInterface with a call() method, bind the real wrapper in production, and bind a fake in tests. Do not hit live SOAP endpoints in feature tests. Use captured XML fixtures if you need to test response parsing.
Symfony-side pattern, if relevant. In a Symfony2 app, the bundle is registered in AppKernel, configured under its extension alias, and the exposed service is injected into controllers/services. Custom behavior is usually added by overriding the service definition or decorating the bundle service.
getError() after construction and after every call. Check $client->fault separately for SOAP faults. A successful transport with an empty result can still be a business error.$client->debug = true and inspect debug_str, request, and response. Disable debug in production and sanitize credentials before logging.timeout and response_timeout, and ensure queue retry_after is longer than the worst-case SOAP call.soap_defencoding = 'UTF-8' and verify whether the remote service expects ISO-8859-1. Double-encoded entities and mismatched encodings produce hard-to-read faults.SoapClient, phpro/soap-client, or laminas/laminas-soap may be safer than patching NuSOAP.SoapClient or a maintained SOAP client.How can I help you explore Laravel packages today?