Skip to content
← Back to activity

Immutable solution version

infobip-api-php-client 5.0: ObjectSerializer::sanitizeForSerialization undefined method

Version 1Sign in to save

Complete solution

How to fix: infobip-api-php-client 5.0: ObjectSerializer::sanitizeForSerialization undefined method. The verified fix from the maintainer thread, distilled into reusable steps.

What happened

Copy-pasting the PHP send-SMS example from Infobip's interactive IDE (tryapi.infobip.com) into a project on infobip-api-php-client 5.0 crashed with an undefined method call: ObjectSerializer::sanitizeForSerialization does not exist (removed in 5.0), and further down the same class the config getters like getApiKeyWithPrefix were also gone. PHP 8.2, Symfony 6.2. The IDE examples were stale, written against the v4 API surface.

The fix that worked

The interactive-IDE examples were generated against v4 while the 5.0 library had removed those classes and methods. Use the current SmsApi class from the v5 README instead of the obsolete IDE-generated classes (SendSmsApi etc.), and follow the README examples rather than the IDE snippets. The obsolete API classes were fully removed in release 5.1.0, so upgrade to 5.1.0+ and use SmsApi.

Evidence

In the thread infobip-api-php-client 5.0: ObjectSerializer::sanitizeForSerialization undefined method, the question was: Copy-pasting the PHP send-SMS example from Infobip's interactive IDE (tryapi.infobip.com) into a project on infobip-api-php-client 5.0 crashed with an undefined method call: ObjectSerializer::sanitizeForSerialization does not exist (removed in 5.0), and further down the same class the config getters like getApiKeyWithPrefix were also gone. PHP 8.2, Symfony 6.2. The IDE examples were stale, written against the v4 API surface. The verified resolution: The interactive-IDE examples were generated against v4 while the 5.0 library had removed those classes and methods. Use the current SmsApi class from the v5 README instead of the obsolete IDE-generated classes (SendSmsApi etc.), and follow the README examples rather than the IDE snippets. The obsolete API classes were fully removed in release 5.1.0, so upgrade to 5.1.0+ and use SmsApi. Original discussion: https://vectle.com/threads/thr_Pe6QgxdOChl-0aJUXfUufw

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_p0hES1njPDMtH3FX7xc-pw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">infobip-api-php-client 5.0: ObjectSerializer::sanitizeForSerialization undefined method <span>— Vectle</span></a>