Php “未知”;pagerfanta“;功能

Php “未知”;pagerfanta“;功能,php,twitter-bootstrap,symfony,pagerfanta,Php,Twitter Bootstrap,Symfony,Pagerfanta,我将Pagerfanta捆绑包与Symfony 3.3.4和Bootstrap 3一起使用 "php": ">=5.5.9", "components/jquery": "^3.2", "doctrine/doctrine-bundle": "^1.6", "doctrine/orm": "^2.5", "incenteev/composer-parameter-handler": "^2.0", "kriswallsmith/assetic

我将Pagerfanta捆绑包与Symfony 3.3.4和Bootstrap 3一起使用

    "php": ">=5.5.9",
    "components/jquery": "^3.2",
    "doctrine/doctrine-bundle": "^1.6",
    "doctrine/orm": "^2.5",
    "incenteev/composer-parameter-handler": "^2.0",
    "kriswallsmith/assetic": "^1.4",
    "oyejorge/less.php": "v1.7.0.14",
    "sensio/distribution-bundle": "^5.0.19",
    "sensio/framework-extra-bundle": "^3.0.2",
    "symfony/assetic-bundle": "^2.8",
    "symfony/monolog-bundle": "^3.1.0",
    "symfony/polyfill-apcu": "^1.0",
    "symfony/swiftmailer-bundle": "^2.3.10",
    "symfony/symfony": "3.3.*",
    "twig/twig": "^1.0||^2.0",
    "twitter/bootstrap": "^3.3",
    "white-october/pagerfanta-bundle": "^1.0"
然后,我的AppBundle中有一个扩展base.html.twig的模板:

{% extends 'base.html.twig' %}

{% block body %}
    <nav class="navbar navbar-inverse navbar-fixed-top">
然后通过页面模板对其进行扩展:

{% extends '@AppBundle/index.html.twig' %}

{% block submenu %}
    <a href="{{ path('site_new') }}" class="btn btn-success"><i class="fa fa-plus"></i> Create</a>
{% endblock %}
{% block title %}
    Manage Sites
{% endblock %}
{% block body %}

    {{ pagerfanta(pager, 'twitter_bootstrap3') }}

{% endblock %}
不管我怎样

Unknown "pagerfanta" function.

Exception: Twig_Error_Syntax

它好像没有包含这个细枝函数,但我看不出还需要包含什么。Pagerfanta也在我的AppKernel.php中

我猜您在呈现此模板附近的某个地方有一个打字错误。将渲染代码添加到问题中,应该是这样的


看起来您忘记了将
WhiteOctoberPagerfantaBundle
添加到
AppKernel.php
,导致未加载
PagerfantaExtension
,因此未定义
{{pagerfanta()}
函数

$bundles = array(
    // ...
    new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
);

我不确定你是否已经绑定了这个,但是你清除了缓存了吗?使用:
php-bin/console-cache:clear--no-warmup--env=prod
甚至
rm-Rf-var/cache
我想你可能已经更改了一些内容,但没有清除缓存。是的,我已经清除了缓存这可能是显而易见的,我对这些东西不是很熟悉,但是你真的创建了Pagerfanta对象并用模板注册了吗?不,这是一个小树枝扩展,我不应该这么做legwork@yceruto,doh,没有添加它,尽管我这么认为。请添加一个答案,以便我可以接受
Unknown "pagerfanta" function.

Exception: Twig_Error_Syntax
$adapter = new DoctrineORMAdapter($queryBuilder);
$pagerfanta = new Pagerfanta($adapter);
    return $this->render('@YourApp/Main/example.html.twig', [
    'my_pager' => $pagerfanta,
]);
$bundles = array(
    // ...
    new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
);