手动配置KnpPaginatorBundle而无需连接互联网

时间:2014-01-29 21:51:49

标签: php symfony-2.4 knppaginator

我需要在断开连接的环境中设置包。我已经阅读了一些关于它的特殊网站,但在以前的版本中。

我正在使用最近下载的Symfony 2.4.1。 我今天下载的KnpPaginatorBundle软件包。

我从GitHub存储库中提取了 master.zip ,其中包含此文件夹:“KnpPaginatorBundle-master”并假设此结构:

 \vendor\Knp\Bundle\PaginatorBundle

enter image description here

我收到此错误:

ClassNotFoundException: Attempted to load class "KnpPaginatorBundle" from namespace "Knp\Bundle\PaginatorBundle" in C:\EasyPHP-DevServer-14.1VC11\data\localweb\projects\sf_zktime\app\AppKernel.php line 20. Do you need to "use" it from another namespace?

这是App_Kernel.php中的第20行:

new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),//Paginator

这是我在供应商包中的本地路径:

C:\EasyPHP-DevServer-14.1VC11\data\localweb\projects\sf_zktime\vendor\Knp\Bundle\PaginatorBundle

这是我的config.yml参数:

knp_paginator:
  page_range: 5 # número de páginas que se muestran en el paginador

  default_options:
    # los siguientes tres parámetros permiten "traducir" el paginador
    # puedes utilizar por ejemplo: 'pagina', 'ordenar' y 'direccion'
    page_name:           page
    sort_field_name:     sort
    sort_direction_name: direction

    # sólo incluir resultados diferentes (útil cuando haces consultas GROUP BY)
    distinct: true

  template:
    # estas opciones configuran la plantilla utilizada para la paginación
    # y para los controles que premiten reordenar los resultados
    pagination: KnpPaginatorBundle:Pagination:sliding.html.twig
    sortable:   KnpPaginatorBundle:Pagination:sortable_link.html.twig

这些参考文献之间的混合:

http://symfony.es/bundles/knplabs/knppaginatorbundle/instalacion-en-symfony-2-1 https://github.com/KnpLabs/KnpPaginatorBundle/

3 个答案:

答案 0 :(得分:0)

修改vendor/composer/autoload_namespaces.php并添加以下行:

'Knp\\Bundle\\PaginatorBundle' => array($vendorDir . '/knplabs/knp-paginator-bundle'),

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

然后删除缓存并重新加载Web服务器。

答案 1 :(得分:0)

修改vendor/composer/autoload_namespaces.php并添加以下行:

'Knp\\Component' => array($vendorDir . '/knplabs/knp-components/src'),
'Knp\\Bundle\\PaginatorBundle' => array($vendorDir . '/knplabs/knp-paginator-bundle'),

它为我工作

问候..

叶诚万

答案 2 :(得分:0)

解决方案是:

1)在cmd中运行:    作曲家需要knplabs / knp-paginator-bundle

2)在autoload_namespaces中添加:    ' KNP \元器件' =>数组($ vendorDir。' / knplabs / knp-components / src'),

3)在config.yml:

 knp_paginator:
     page_range: 5 # number of pages displayed in the paginator.

     default_options:
        # the following three parameters allow "translate" the paginator.
        # you can use eg 'page', 'order' and 'direction'
        page_name:           page
        sort_field_name:     sort
        sort_direction_name: direction

        # only include different results (useful when you do GROUP BY 
        #  queries)                   
        distinct: true

    template:
        # these options configure the template used for pagination.
        # and the controls that allow you to sort the results
        pagination: KnpPaginatorBundle:Pagination:sliding.html.twig
        sortable:   KnpPaginatorBundle:Pagination:sortable_link.html.twig

4)在Appkernel.php中添加:             新的Knp \ Bundle \ PaginatorBundle \ KnpPaginatorBundle(),

5)在cmd运行中:             php app / console cache:clear

6)重新加载浏览器。

7)最后,它有效!