how to solve Illuminate/database syntax error on ForwardsCalls trait

时间:2018-09-18 08:49:03

标签: php slim

This is just happening today when I'm updating my website. Actually I didn't even touch this file but for some reason it shows error and my website can't be loaded.

Here is the problem

try {
        return $object->{$method}(...$parameters);
    } catch (Error | BadMethodCallException $e) { // "|" << this is the error
        $pattern = '~^Call to undefined method (?P<class>[^:]+)::(?P<method>[^\(]+)\(\)$~';

        if (! preg_match($pattern, $e->getMessage(), $matches)) {
            throw $e;
        }

        if ($matches['class'] != get_class($object) ||
            $matches['method'] != $method) {
            throw $e;
        }

        static::throwBadMethodCallException($method);
    }

I have tried to search about catch one of two exception but none. How can I solve this. I don't even know about trait. Thanks before

1 个答案:

答案 0 :(得分:1)

来自exceptions documentation

  

PHP 7.1 和更高版本中,catch块可以指定多个异常   使用竖线(|)字符。

您正在使用PHP较新版本的计算机上进行开发,但在较旧的版本上进行部署。您确实应该考虑在两台计算机上使用完全相同的PHP版本,以避免向后兼容性问题。

要解决您的问题,如果托管公司提供了这样的功能,则可以选择更高版本的PHP,或者将您正在使用的库降级为与您的主机的PHP版本兼容的版本。我不建议使用第二种方法,降级软件包以处理过时的依赖关系不是一个好主意。