简体   繁体   English

如何使Apigility正常工作?

[英]How to get Apigility working correctly?

I am working on installing Apigility on a Linux web server. 我正在在Linux Web服务器上安装Apigility。 It is a shared hosting account with Inmotion Hosting. 它是Inmotion Hosting的共享托管帐户。 I am using the instructions at https://apigility.org/documentation/intro/installation . 我正在使用https://apigility.org/documentation/intro/installation上的说明。 It was really easy to install, but I running into syntax error that I can't figure out. 这确实很容易安装,但是我遇到了语法错误,无法弄清。

Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /home/amlcon5/public_html/websites/dev/apigility/vendor/zendframework/zend-servicemanager/src/ServiceManager.php on line 281

Here is the function from ServiceManager.php where the error is. 这是错误所在的ServiceManager.php中的函数。

/**
 * Set factory
 *
 * @param  string                           $name
 * @param  string|FactoryInterface|callable $factory
 * @param  bool                             $shared
 * @return ServiceManager
 * @throws Exception\InvalidArgumentException
 * @throws Exception\InvalidServiceNameException
 */
public function setFactory($name, $factory, $shared = null)
{
    $cName = $this->canonicalizeName($name);

    if (!($factory instanceof FactoryInterface || is_string($factory) || is_callable($factory))) {
        throw new Exception\InvalidArgumentException(sprintf(
            'Provided factory must be the class name of a factory, callable or an instance of "%s".',
            FactoryInterface::class // <--- ERROR IS HERE
        ));
    }

    if ($this->has([$cName, $name], false)) {
        if ($this->allowOverride === false) {
            throw new Exception\InvalidServiceNameException(sprintf(
                'A service by the name or alias "%s" already exists and cannot be overridden, please use an alternate name',
                $name
            ));
        }
        $this->unregisterService($cName);
    }

    if ($shared === null) {
        $shared = $this->shareByDefault;
    }

    $this->factories[$cName] = $factory;
    $this->shared[$cName]    = (bool) $shared;

    return $this;
}

I have tried several things, such as: reinstalling using other methods, disabling OpCache, and reviewing the config files. 我已经尝试了几件事,例如:使用其他方法重新安装,禁用OpCache和查看配置文件。

Has anyone experienced this when setting up Apigility or know how to fix this? 有人在设置Apigility时经历过此事,或者知道如何解决此问题?

Turns out I wasn't up to date on PHP. 原来我不是最新的PHP。 Updated to PHP5.5 and it worked. 更新到PHP5.5,它起作用了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM