knp_paginator 无法打开流

Posted

技术标签:

【中文标题】knp_paginator 无法打开流【英文标题】:knp_paginator failed to open stream 【发布时间】:2015-03-01 12:01:49 【问题描述】:

更新到 Symfony 2.6 后,使用 kn._paginator 的页面不再加载:

An exception has been thrown during the rendering of a template 
("Warning: file_get_contents(/Users/steve/dev/sites/virtual/newgt/
vendor/knplabs/knp-paginator-bundle/Knp/Bundle/PaginatorBundle/Resources/views
/Pagination/sliding.html.twig): 
failed to open stream: No such file or directory") in
NewgtMediaBundle:Default:showSeriesSeason.html.twig at line 32


Config.yml ::
# KNP Paginator
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

请求的模板:

/Users/steve/dev/sites/virtual/newgt/vendor/knplabs/knp-paginator-bundle/Knp/Bundle/PaginatorBundle/Resources/views/Pagination/sliding.html.twig 

实际存在于:

/Users/steve/dev/sites/virtual/newgt/vendor/knplabs/knp-paginator-bundle/Resources/views/Pagination/sliding.html.twig

如何告诉我的应用 knp_paginator 应该在哪里寻找模板?

【问题讨论】:

如果 template: pagination: 被注释掉,那么页面会为 app_dev.php 正确加载 【参考方案1】:

更新 config.yml

knp_paginator:
....
    template:
        # Following two lines were present before Symfony 2.6 upgrade. 
        # Commented out to load from default location.
        # pagination: KnpPaginatorBundle:Pagination:sliding.html.twig     # sliding pagination
        # sortable: KnpPaginatorBundle:Pagination:sortable_link.html.twig # sort link template

然后

sudo rm -rf app/cache/prod 
app/console cache:clear –env=prod

(与 --env=dev 相同)

两者http://mysite/app_dev.php/media/gallery/24223?page=5&count=82&number=1752&series=FIAGT&season=2009 和 http://mysite/media/gallery/24223?page=5&count=82&number=1752&series=FIAGT&season=2009

又开始工作了。

【讨论】:

以上是关于knp_paginator 无法打开流的主要内容,如果未能解决你的问题,请参考以下文章

无法打开流或文件:无法打开流:权限被拒绝

“无法打开流或文件“laravel.log”:无法打开流:权限被拒绝”

无法打开流或文件“/app/storage/logs/laravel.log”:无法打开流:权限被拒绝

我收到错误日志文件的消息“无法打开流或文件“.../laravel.log”:无法打开流:权限被拒绝” [重复]

无法打开 geoip.dat 文件。即使文件存在,“无法打开流”

xampp ubuntu laravel 无法打开流或文件“/storage/logs/laravel log”:无法打开流:权限被拒绝