PHP “Exception not found”

后端 未结 3 1810
半阙折子戏
半阙折子戏 2021-02-12 22:15

I have a somehow funny issue. While trying to understand why a certain website returns http code 500 to browser, I found the message

PHP Fatal error:  Class \'MZ         


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-12 22:57

    The MZMailChimpBundle does not contain a class named Exception within the MZ\MailChimpBundle\Services namespace.

    Because of that simple fact and as the error message that the exception should signal is related to an integration problem (check for the curl library) I assume that this is a bug.

    The original has meant \Exception and not Exception here. It's a somewhat common mistake that can happen with namespaces. To fix the file, either alias/import \Exception as Exception:

    namespace MZ\MailChimpBundle\Services;
    use Exception;
    

    and/or change the new line in MZMailChimpBundle/Services/MailChimp.php:

    throw new \Exception('This bundle needs the cURL PHP extension.');
    

    See as well the related question: How to use “root” namespace of php? and the one with the same Class 'Namespace\Example' not found error message: Calling a static method from a class in another namespace in PHP.

提交回复
热议问题