I created a Symfony command that parses an IMAP mailbox. The IMAP extension is installed and enabled.
When I execute the command I have this error:
[Symfony\Component\Debug\Exception\UndefinedFunctionException]
Attempted to call function "imap_open" from namespace "CAB\MainBundle\Imap".
But through the browser, I haven't this error and the imap_open
is executed without error.
Why the imap_open
doesn't exist when it is executed from the console?
In the server, there are two PHP versions installed : PHP5.6 and PHP7. The IMAP extension is enabled in PHP 5.6 but it is not enabled for PHP 7.
So when I run the command with php app/console parse:mailbox
it calls the PHP7 and since the imap extension isn't enabled for PHP7 the code throws an UndefinedFunctionException
exception
The right way is to execute the command with php5.6
php5.6 app/console parse:mailbox