Php Twig无法在live Environment上传递可选参数

Php Twig无法在live Environment上传递可选参数,php,twig,silex,Php,Twig,Silex,我在细枝模板中有以下行: {% for line in order.getItems() %} {% set os = line.option.getOverstock(true)|first %} 指的是这种方法: public function getOverstock($getQtyOrdering = false) { if ($getQtyOrdering === false) { return $this->overstock;

我在细枝模板中有以下行:

{% for line in order.getItems() %}
    {% set os = line.option.getOverstock(true)|first %}
指的是这种方法:

public function getOverstock($getQtyOrdering = false) {
        if ($getQtyOrdering === false) {
            return $this->overstock;
        }

        //sort the collection by the quantity field before returning
        $iterator = $this->overstock->getIterator();
        $iterator->uasort(function ($a, $b) {
            return ($a->getQty() < $b->getQty()) ? 1 : -1;
        });
        $sortResult = new \Doctrine\Common\Collections\ArrayCollection(iterator_to_array($iterator));
        return $sortResult;

    }
公共函数getOverstock($getQtyOrdering=false){
如果($GetQTyorOrdering==false){
返回$this->积压;
}
//在返回之前,按数量字段对集合进行排序
$iterator=$this->overstock->getIterator();
$iterator->uasort(函数($a,$b){
返回($a->getQty()<$b->getQty())?1:-1;
});
$sortResult=new\Doctrine\Common\Collections\ArrayCollection(迭代器到数组($迭代器));
返回$sortResult;
}
在我的开发环境中,这工作得很好,但在live上,参数没有传递给方法。我已经检查了live和dev的副本,它们彼此之间以及我们的存储库—一切看起来都很好

如何调试这种情况

(我在silex框架中工作)

您可以使用dump函数输出此变量

或通过以下方式添加symfony软件包
symfony/var转储程序

composer require symfony/var-dumper
向细枝添加转储功能

$app->extend('twig', function ($twig) use ($app, $request) {
    $twig->addFunction('dump', new \Twig_SimpleFunction('dump', '\dump'));

    return $twig;
});
并在模板中输出此变量

{% for line in order.getItems() %}
    {{ dump(line.option.getOverstock(true)|first) }}
    {{ dump(line.option.getOverstock(true)) }}
    {{ dump(line) }}
    {% set os = line.option.getOverstock(true)|first %}
您可以使用dump函数输出此变量

或通过以下方式添加symfony软件包
symfony/var转储程序

composer require symfony/var-dumper
向细枝添加转储功能

$app->extend('twig', function ($twig) use ($app, $request) {
    $twig->addFunction('dump', new \Twig_SimpleFunction('dump', '\dump'));

    return $twig;
});
并在模板中输出此变量

{% for line in order.getItems() %}
    {{ dump(line.option.getOverstock(true)|first) }}
    {{ dump(line.option.getOverstock(true)) }}
    {{ dump(line) }}
    {% set os = line.option.getOverstock(true)|first %}