imap extension requires libc-client library, provided by uw-imap project which is dead for years (last version from 2007)
Nobody should use it.
imap extension have recently been removed from PHP (and moved to pecl) for this reason.
Some pure-PHP alternatives exist, ex laminas-mail - Laminas Docs
Indeed, available in my repository, provided for legacy applications.