Php 您请求了一项不存在的服务“;knp_paginator";。
我已经创建了savvy contact form bundle,它工作正常,但我想使用knp分页bundle显示所有带有分页的联系人表数据,但它不工作,因此请帮助我解决此问题 我遇到了这个错误Php 您请求了一项不存在的服务“;knp_paginator";。,php,symfony,symfony-forms,Php,Symfony,Symfony Forms,我已经创建了savvy contact form bundle,它工作正常,但我想使用knp分页bundle显示所有带有分页的联系人表数据,但它不工作,因此请帮助我解决此问题 我遇到了这个错误 FileLoaderLoadException: Cannot import resource "C:\wamp\www\Acme\app/config\config.yml" from "C:\wamp\www\Acme\app/config/config_dev.yml". (There is no
FileLoaderLoadException: Cannot import resource "C:\wamp\www\Acme\app/config\config.yml" from "C:\wamp\www\Acme\app/config/config_dev.yml". (There is no extension able to load the configuration for "knp_paginator" (in C:\wamp\www\Acme\app/config\config.yml). Looked for namespace "knp_paginator", found "framework", "security", "twig", "monolog", "swiftmailer", "assetic", "doctrine", "sensio_framework_extra", "savvy_contact", "web_profiler", "sensio_distribution")
*这是我的config.yml*
imports:
- { resource: parameters.yml }
- { resource: security.yml }
framework:
#esi: ~
translator: { fallback: "%locale%" }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_proxies: ~
session: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver, add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
knp_paginator:
page_range: 10 # 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
这是我的ContactController.php
<?php
namespace Savvy\ContactBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Savvy\ContactBundle\Form\ContactType;
use Savvy\ContactBundle\Entity\Contact;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
class ContactController extends Controller
{
/**
* @Route("/contact", name="savvy_contact")
* @Template()
*/
public function indexAction()
{
$form = $this->createForm(new ContactType());
return array(
'form' => $form->createView()
);
}
/**
* @Route("/contact/submit", name="savvy_submit_contact")
* @Method("POST")
* @Template("SavvyContactBundle:Contact:index.html.twig")
*/
public function submitAction()
{
//Create a new contact entity instance
$contact = new Contact();
$form = $this->createForm(new ContactType(), $contact);
//Bind the posted data to the form
$form->bind($this->getRequest());
//Make sure the form is valid before we persist the contact
if($form->isValid()){
//Get the entity manager and persist the contact
$em = $this->getDoctrine()->getManager();
$em->persist($contact);
$em->flush();
//Redirect the user and add a thank you flash message
return $this->redirect($this->generateUrl("savvy_contact"));
}
return array(
'form' => $form->createView()
);
}
/**
* @Route("/show", name="savvy_show")
* @Template("SavvyContactBundle:Contact:show.html.twig")
*/
public function showAction() {
$em = $this->getDoctrine()->getManager();
//
//$entities = $em->getRepository('QsystemsUserBundle:Printer')->findAll();
$dbl = 'SELECT c FROM SavvyContactBundle:Contact c';
$query = $em->createQuery($dbl);
$paginator = $this->get('knp_paginator');
$pagination = $paginator->paginate(
$query,
$this->get('request')->query->get('page', 1)/*page number*/,
10/*limit per page*/
);
return $this->render('SavvyContactBundle:Contact:show.html.twig', array(
'pagination' => $pagination,
));
}
}
您确定您的Knp Paginator捆绑包已成功安装吗
composer.json:
"knplabs/knp-paginator-bundle": "~2.4"
做:
app/AppKerner.php:
new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
然后检查:
php app/console cache:clear
您确定您的Knp Paginator捆绑包已成功安装吗
composer.json:
"knplabs/knp-paginator-bundle": "~2.4"
做:
app/AppKerner.php:
new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
然后检查:
php app/console cache:clear
您是否已将相关捆绑包添加到AppKernel.php
文件中?您是否已将相关捆绑包添加到AppKernel.php
文件中?嘿,我正在使用netbeans,我已成功安装knp paginator捆绑包。您是否已完成此处提到的所有过程,但仍然存在错误。请评论新行Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),从AppKernel.php开始,然后执行php composer.phar更新Knp-paginator Bundle,然后执行php应用程序/控制台缓存:清除,最后取消对AppKernel.php行的注释我已使用composer以以下版本“knplabs/Knp组件”安装了它:“1.2.1”,“knplabs/Knp-paginator Bundle”:“2.3.2”,谢谢,伙计,我忘了添加bundle新的Knp\bundle\PaginatorBundle\KnpPaginatorBundle(),你的welcom;),有效答案plz:pHey我正在使用netbeans,我已经成功安装了knp paginator捆绑包。完成了您在这里提到的所有过程,但仍然存在错误。请在AppKernel.php中注释行new knp\bundle\PaginatorBundle\KnpPaginatorBundle(),然后执行php composer.phar更新knp paginator捆绑包,然后是php应用程序/控制台缓存:清除,最后取消对AppKernel.php行的注释我已经使用composer安装了它,版本为“knplabs/knp components”:“1.2.1”,“knplabs/knp paginator bundle”:“2.3.2”,谢谢,我忘了添加bundle新的knp\bundle\PaginatorBundle\KNPAginatorbundle(),你的welcom;),有效答案plz:p