PHP-IMAP is a wrapper for common IMAP communication without the need to have the php-imap module installed / enabled. The protocol is completely integrated and therefore supports IMAP IDLE operation and the "new" oAuth authentication process as well.
// Get the messages in the inbox $messages = $folder->messages()->all();
// Paginate the messages in descending order and retrieve 5 items per page $messages = $messages->setFetchOrder("desc")->paginate(5);
// Reverse the order of the paginated results without creating a new instance $messages->setCollection(collect(array_reverse($messages->items())));
to imap.php
'fetch_order' => 'desc',