PHPackages                             php-soap/encoding - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. php-soap/encoding

ActiveLibrary[API Development](/categories/api)

php-soap/encoding
=================

SOAP encoding and decoding package

0.34.0(1mo ago)9410.4k↓34.4%4[2 PRs](https://github.com/php-soap/encoding/pulls)5MITPHPPHP ~8.4.0 || ~8.5.0CI passing

Since Jun 10Pushed 1mo ago3 watchersCompare

[ Source](https://github.com/php-soap/encoding)[ Packagist](https://packagist.org/packages/php-soap/encoding)[ Fund](https://opencollective.com/php-soap)[ RSS](/packages/php-soap-encoding/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (10)Dependencies (111)Versions (41)Used By (5)

Encoding
========

[](#encoding)

This package provides a pure PHP drop-in replacement for the `ext-soap` encoding logic. It can be used as a driver so that you don't have to install PHP's soap extension on your machine anymore.

Thanks
======

[](#thanks)

This project was funded by the sponsorship of [buhta.com](https://buhta.com).

[![buhta.com](docs/buhta.svg)](https://buhta.com)

Want to help out? 💚
===================

[](#want-to-help-out-)

- [Become a Sponsor](https://github.com/php-soap/.github/blob/main/HELPING_OUT.md#sponsor)
- [Let us do your implementation](https://github.com/php-soap/.github/blob/main/HELPING_OUT.md#let-us-do-your-implementation)
- [Contribute](https://github.com/php-soap/.github/blob/main/HELPING_OUT.md#contribute)
- [Help maintain these packages](https://github.com/php-soap/.github/blob/main/HELPING_OUT.md#maintain)

Want more information about the future of this project? Check out this list of the [next big projects](https://github.com/php-soap/.github/blob/main/PROJECTS.md) we'll be working on.

Installation
============

[](#installation)

```
composer require php-soap/encoding
```

Example usage
-------------

[](#example-usage)

```
use Soap\Encoding\Driver;
use Soap\Encoding\EncoderRegistry;
use Soap\Engine\SimpleEngine;
use Soap\Psr18Transport\Psr18Transport;
use Soap\Wsdl\Loader\StreamWrapperLoader;
use Soap\WsdlReader\Locator\ServiceSelectionCriteria;
use Soap\WsdlReader\Model\Definitions\SoapVersion;
use Soap\WsdlReader\Wsdl1Reader;

// Loads the WSDL with the php-soap/wsdl-reader package:
$wsdl = (new Wsdl1Reader(new StreamWrapperLoader()))($wsdlLocation);

// Create an engine based on the encoding system that is provided by this package:
$engine = new SimpleEngine(
    Driver::createFromWsdl1(
        $wsdl,
        ServiceSelectionCriteria::defaults()
            ->withPreferredSoapVersion(SoapVersion::SOAP_12),
        EncoderRegistry::default(),
    ),
    Psr18Transport::createForClient($httpClient)
);

// Perform requests:
$decodedResult = $engine->request('Add', [
    [
        'a' => 1,
        'b' => 2
    ]
]);

/*
RESULT :

class stdClass#2135 (1) {
  public $AddResult =>
  int(3)
}
 */
```

EncoderRegistry
---------------

[](#encoderregistry)

The `EncoderRegistry` is a collection of encoders that can be used to encode and decode data. By default, we provide a broad set of encoders to perform the basic soap encoding logic. However, you can configure how the encoding should be done by adding your own encoders to the registry.

Some examples:

```
use Soap\Encoding\ClassMap\ClassMap;
use Soap\Encoding\ClassMap\ClassMapCollection;
use Soap\Encoding\Encoder\SimpleType\DateTimeTypeEncoder;
use Soap\Encoding\EncoderRegistry;
use Soap\Xml\Xmlns;

EncoderRegistry::default()
    ->addClassMap('urn:namespace', 'TypeA', TypeA::class)
    ->addClassMap('urn:namespace', 'TypeB', TypeB::class)
    ->addClassMapCollection(new ClassMapCollection(
        new ClassMap('urn:namespace', 'TypeC', TypeC::class),
    ))
    ->addBackedEnum('urn:namespace', 'EnumA', EnumA::class)
    ->addSimpleTypeConverter(Xmlns::xsd()->value(), 'dateTime', new DateTimeTypeEncoder('Y-m-d\TH:i:s'))
    ->addComplexTypeConverter('urn:namespace', 'TypeC', MySpecificTypeCEncoder::class);
```

Encoder
-------

[](#encoder)

Encoding and decoding is based on small `XmlEncoder` classes that are responsible for encoding and decoding a specific type of data. You can either use one of the provided encoders or create your own.

Building a custom encoder can look like this:

```
use Soap\Encoding\Encoder\Context;
use Soap\Encoding\Encoder\XmlEncoder;
use VeeWee\Reflecta\Iso\Iso;

/**
 * @implements XmlEncoder
 */
class MySpecificTypeCEncoder implements XmlEncoder
{
    /**
     * @return Iso
     */
    public function iso(Context $context) : Iso
    {
        return new Iso(
            to: static fn (MyClass $value): string => $myClass->toXmlString(),
            from: static fn (string $value) => MyClass::fromXmlString($value),
        );
    }
}
```

**Note:** An encoder is considered to be isomorphic : When calling `from` and `to` on the `Iso` object, the data should be the same. More information about the concept [can be found here](https://github.com/veewee/reflecta/blob/main/docs/isomorphisms.md).

For a full list of available encoders, you can check the [Soap\\Encoding\\Encoder](src/Encoder) namespace. There are also some examples of common problems you can solve with these encoders in the [examples/encoders](examples/encoders) directory.

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance93

Actively maintained with recent releases

Popularity45

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 98.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~18 days

Total

39

Last Release

38d ago

PHP version history (4 changes)0.1.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0

0.13.0PHP ~8.2.0 || ~8.3.0 || ~8.4.0

0.23.0PHP ~8.3.0 || ~8.4.0 || ~8.5.0

0.32.0PHP ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c0cb7e57de4834c7e94552864acb7c5640725b5ec0ea8f087ebbf6761dd3c206?d=identicon)[veewee](/maintainers/veewee)

---

Top Contributors

[![veewee](https://avatars.githubusercontent.com/u/1618158?v=4)](https://github.com/veewee "veewee (188 commits)")[![ademarco](https://avatars.githubusercontent.com/u/153362?v=4)](https://github.com/ademarco "ademarco (1 commits)")[![EJTJ3](https://avatars.githubusercontent.com/u/31619091?v=4)](https://github.com/EJTJ3 "EJTJ3 (1 commits)")

---

Tags

hacktoberfest

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/php-soap-encoding/health.svg)

```
[![Health](https://phpackages.com/badges/php-soap-encoding/health.svg)](https://phpackages.com/packages/php-soap-encoding)
```

###  Alternatives

[veewee/xml

XML without worries

1837.0M39](/packages/veewee-xml)[phpro/soap-client

A general purpose SoapClient library

8896.1M54](/packages/phpro-soap-client)[php-soap/wsdl

Deals with WSDLs

184.0M19](/packages/php-soap-wsdl)[php-soap/wsdl-reader

A WSDL reader in PHP

212.7M18](/packages/php-soap-wsdl-reader)[roave/backward-compatibility-check

Tool to compare two revisions of a public API to check for BC breaks

6003.7M96](/packages/roave-backward-compatibility-check)[veewee/reflecta

Unleash the Power of Optics in your code!

13422.0k7](/packages/veewee-reflecta)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
