Back to blog
laravel soap testing

Zoap 1.1 - five years later, tested on PHP 7.3 through 8.5

December 2, 2026

Zoap turns any PHP class into a SOAP service in Laravel. You point a config entry at a class, and it generates the WSDL from your DocBlocks and handles requests through the Laminas SOAP components. No XML wrangling, no hand-written WSDL.

The last release, 1.0.5, shipped in February 2021. Since then PHP has gone from 8.0 to 8.5 and Laravel from 8 to 13. Zoap had a Postman collection but no automated tests, so we couldn't say for sure whether it still worked.

We set out to find out, and to ship a release we could actually vouch for.

The plan we didn't follow

The first plan was a ladder of releases, each pinned to one laminas-soap version:

Zoap laminas-soap PHP
1.1 2.9 7.3 - 8.0
1.2 2.12 8.0 - 8.2
1.3 2.14 8.1 - 8.4
1.4 2.15 8.2 - 8.5

Then we diffed laminas-soap 2.9 against 2.15. Every method Zoap calls - AutoDiscover, Wsdl::addType, Server::handle, DocumentLiteralWrapper - has the same signature in both. The releases in between are almost entirely "allow PHP 8.x" changes.

Composer already solves this problem. Given a version range, it installs the newest release that supports the user's PHP. Four Zoap releases would mean four branches and every future fix backported three times, all to reproduce what one constraint does for free.

So Zoap 1.1 is a single release:

"laminas/laminas-soap": ">=2.9.0 <2.16.0"

The old constraint was ^2.9, which also accepts laminas releases nobody has tested yet. The upper bound keeps an untested 2.16 from slipping in; when it ships, we test it and widen the range.

It mostly still worked

We set up a Laravel test site for every PHP version from 8.0 to 8.5, each on a different Laravel version from 8 to 13, and installed the old 1.0.5 on all of them.

The core of it worked everywhere. WSDL generation, every Demo operation, round trips through PHP's native SoapClient - all fine, on every combination.

The failures were all in the same place: what happens when something goes wrong.

Bug 1: the fault template that PHP tried to execute

When the controller catches an exception, it renders a SOAP fault from a Blade template that starts like this:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope ...>

With PHP's short_open_tag setting enabled, <? opens a PHP block, and PHP tries to run xml version="1.0"... as code. The result is a parse error, and instead of a SOAP fault the client gets Laravel's HTML error page.

You'd assume nobody enables short_open_tag. But On is PHP's built-in default. The recommended php.ini-production turns it off, which is why this mostly hides in production - but any PHP running without an ini file, like Laravel Herd's, has it on. There, controller-level faults in 1.0.5 rendered an HTML error page instead.

The fix is to never let the characters <? appear in the template source:

{!! '<' . '?xml version="1.0" encoding="UTF-8"?' . '>' !!}

Wrapping the declaration in {!! !!} alone isn't enough. Blade only compiles the parts of a template that PHP's tokenizer sees as plain HTML, and once <? has opened a PHP block, Blade never sees the echo at all.

While we were in there: the fault message was output with {!! !!}, unescaped. An exception message containing < or & produced invalid XML. It's {{ }} now.

Bug 2: a server that calls itself

To handle a request, Zoap gave the Laminas server the URL of its own WSDL:

$server = new Server($this->endpoint . '?wsdl');

So every SOAP call made a second HTTP request back to the same app to fetch the WSDL. That doubles the work on every call, and under php artisan serve it deadlocks: the built-in server handles one request at a time, so the inner request waits forever for the outer one to finish. This was reported in an open issue.

1.1 generates the WSDL in-process and hands it to the server as a temporary file. No self-requests, no deadlock.

Bug 3: status codes that depended on the server

On faults, 1.0.5 did this:

$output->headers->set("Status", 500);

That doesn't set the HTTP status. It adds a response header literally named Status. It happened to work behind PHP-FPM, which (like CGI) interprets a Status header as the response code. Under artisan serve, Laravel Octane, or Laravel's own test client, faults came back as HTTP 200.

1.1 uses setStatusCode(500), and every fault returns 500 everywhere, as SOAP 1.1 specifies. That includes faults thrown directly from a service class, which the native SOAP server renders on its own - the controller now inspects the response and sets the status when it finds a fault.

Bug 4: superglobals

The controller read $_GET['wsdl'], and Laminas read the request body from php://input. Both work in a classic request lifecycle and break under Octane, which reuses the process across requests. A community pull request proposed reading both from the Laravel request instead. 1.1 does that, resolving the request through the container so Lumen keeps working.

That change also made the package testable. Laravel's HTTP test client builds a request object without touching superglobals, so the old code couldn't be exercised in-process at all.

Testing it

1.1 ships with a proper test suite, in two layers.

In-process tests run on Orchestra Testbench: every Demo operation, every fault path, every complex-type strategy, registered and unregistered exceptions, PHP errors, missing config keys, and a WSDL snapshot.

Live tests run the same scenarios over real HTTP against any running app, including through PHP's native SoapClient. Point them at a URL:

ZOAP_LIVE_URL=http://zoap-test.test vendor/bin/phpunit --testsuite Live

The scenarios live in a shared trait, so the two suites can't drift apart. Only the transport differs.

CI runs the in-process suite across 32 combinations: PHP 7.3 through 8.5, Laravel 8 through 13, each with both the newest and the oldest laminas-soap release Composer will install. That second axis matters. A loose constraint is only honest if the bottom of the range works too.

1.0.5 1.1
Tests Postman collection 34 in-process, 13 live
CI none 32 jobs, PHP 7.3 - 8.5
Faults under artisan serve / Octane HTTP 200 or hang HTTP 500
Controller faults with short_open_tag on HTML error page SOAP fault
Requests per SOAP call 2 1

Upgrading

composer require viewflex/zoap:^1.1

1.1 requires PHP 7.3+ and Laravel 8+ - older apps can stay on 1.0.x. The changes you might notice:

  • Faults always return HTTP 500. Behind PHP-FPM, the Demo service used to return 401 or 400 for bad credentials.
  • Unregistered exceptions and PHP errors return "Unknown error" instead of their message, so internal details stay out of responses. They're still logged if logging is enabled.
  • If you published the fault view, re-publish it. Your copy still has the <?xml problem.

The full list is in the changelog.

The takeaway

The code paths that broke were the ones nobody had reason to look at. Five years of PHP and Laravel releases left the happy path intact. Error handling degraded quietly, in ways that depended on server configuration.

Happy paths survive years of upgrades; error paths quietly don't. Test them, and on more than one kind of server.


Zoap is free and open source under the MIT license. Source and issues are on GitHub.