1

当我使用 Symfony 2.4配置Knp 分页器捆绑包时出现此错误

错误: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(),
4

1 回答 1

0

将您的插件文件夹移动到vendor/knplabs/knp-paginator-bundle/,所以现在真正的路径是:vendor/knplabs/knp-paginator-bundle/Knp/Bundle/PaginatorBundle/

于 2014-03-04T16:19:45.593 回答