b85411
b85411

Reputation: 10010

Unable to load knp_paginator bundle

I am getting the following error when I try to clear the cache in Symfony:

"Cannot import resource C:...\config.yml from "C:...\config_dev.yml" (There is no extension able to load the configuration for "knp_paginator")..."

And it goes on to say:

"Looked for namespace "knp_paginator", found "framework", "security", "twig", etc etc"

It happens when I put the config settings suggested at https://github.com/KnpLabs/KnpPaginatorBundle into my config.yml file:

# Pagination
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

What am I doing wrong?

Upvotes: 1

Views: 2019

Answers (2)

Ayoub Jawadi
Ayoub Jawadi

Reputation: 11

for symfony 5 : add Knp\Bundle\PaginatorBundle\KnpPaginatorBundle::class=> ['all' => true],

in config/bundles.php

Upvotes: 1

b85411
b85411

Reputation: 10010

Discovered what it was:

I needed to add the bundle to the application kernel. In app/AppKernel.php, the function registerBundles() I needed to add:

new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),

And that fixed it.

Upvotes: 5

Related Questions