Symfony 2.4:Knp paginator Bundle安装问题

时间:2014-03-04 16:12:02

标签: php symfony pagination knppaginator

我在使用Symfony 2.4

配置Knp paginator Bundle时遇到此错误

错误: ClassNotFoundException:尝试从D:\ Projects \ wamp \ www \ Stutorial \ app \ AppKernel.php第29行中的命名空间“Knp \ Bundle \ PaginatorBundle”加载类“KnpPaginatorBundle”。您是否需要从另一个命名空间“使用”它?

我按照以下步骤安装Knp paginator Bundle

# Install Knp components
git clone git://github.com/KnpLabs/knp-components.git vendor/knp-components

# Install knp paginator bundle
git clone git://github.com/KnpLabs/KnpPaginatorBundle.git vendor/bundles/Knp/Bundle/PaginatorBundle

我的config.yml文件:

knp_paginator:
    page_range: 5                      # default page range used in pagination control
    default_options:
        page_name: page                # page query parameter name
        sort_field_name: sort          # sort field query parameter name
        sort_direction_name: direction # sort direction query parameter name
        distinct: true                 # ensure distinct results, useful when ORM queries are using GROUP BY statements
    template:
        pagination: KnpPaginatorBundle:Pagination:sliding.html.twig     # sliding pagination controls template
        sortable: KnpPaginatorBundle:Pagination:sortable_link.html.twig # sort link template

我在autoload_namespaces.php中添加了两行

'Knp\\Component'      => array($vendorDir.'/knp-components/src'),
'Knp\\Bundle'         => array($vendorDir.'/bundles'),

此行到AppKernel.php文件

new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),

1 个答案:

答案 0 :(得分:0)

将您的插件文件夹移至vendor/knplabs/knp-paginator-bundle/,现在真正的路径为:vendor/knplabs/knp-paginator-bundle/Knp/Bundle/PaginatorBundle/