How to add standard PHP extensions?


I have a project which has ext-snmp as a composer dependency. On Travis, composer chokes at this point because the snmp extension isn’t enabled. It’s not in the ‘pre-installed modules’ list, but it would normally be built as part of the PHP build (not a pecl module).

How do I get it enabled? In particular, in a way that works across PHP 5.6, 7.0, 7.1 and 7.2?