2016-11-25 75 views
0

我有Symfony微内核,我试图添加FOSUserBundle。 通过这个指南会后进行安装https://symfony.com/doc/master/bundles/FOSUserBundle/index.html我买了 'validor.builder'Symfony3你已经要求一个不存在的服务“validator.builder”,而添加FOSUserBundle

Fatal error: Uncaught Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "validator.builder". in /var/www/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php on line 754 

调用堆栈

/app_dev.php:0的Symfony \部件错误\ HttpKernel \内核级>处理( ).../app_dev.php:9 Symfony \ Component \ HttpKernel \ Kernel-> boot( ).../Kernel.php:166 Symfony \ Component \ HttpKernel \ Kernel-> initializeContainer( ).. ./Kernel.php:117 Symfony \ Component \ DependencyInjection \ ContainerBuilder-> compile(0123编译器编译( ).../ContainerBuilder.php:528 FOS \ UserBundle \ DependencyInjection \ Compiler \ ValidationPass-> process(())/ Kernel.php:477 Symfony \ Component \ DependencyInjection \ Compiler \ Compiler-> ).../Compiler.php:104 的Symfony \元器件\ DependencyInjection \ ContainerBuilder-> getDefinition方法( ).../ValidationPass.php:41

它接缝该symfony中找不到服务验证器。 builder,与symfony FrameworkBundle一起使用。 有没有人有建议,问题在哪里,缺少什么? 谢谢!

Composer.json:

{ 
    "require": { 
     "symfony/symfony": "^3.1", 
     "symfony/security": "^3.1", 
     "symfony/monolog-bundle": "^3.0", 
     "twig/twig": "^1.28", 
     "alcaeus/mongo-php-adapter": "^1.0", 
     "ext-mongo": "*", 
     "mongodb/mongodb": "^1.0", 
     "doctrine/mongodb-odm": "^1.1", 
     "doctrine/mongodb-odm-bundle": "^3.2", 
     "friendsofsymfony/user-bundle": "[email protected]", 
     "symfony/validator": "^3.1" 
    }, 
    "autoload": { 
     "psr-4": { 
      "": "src/" 
     } 
    } } 

App_dev.php

<?php 

use Symfony\Component\HttpFoundation\Request; 

require __DIR__.'/../app/AppKernel.php'; 

$kernel = new AppKernel('dev', true); 
$request = Request::createFromGlobals(); 
$response = $kernel->handle($request); 
$response->send(); 
$kernel->terminate($request, $response); 

AppKernel.php

<?php 

use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; 
use Symfony\Component\Config\Loader\LoaderInterface; 
use Symfony\Component\DependencyInjection\ContainerBuilder; 
use Symfony\Component\HttpKernel\Kernel; 
use Symfony\Component\Routing\RouteCollectionBuilder; 

// require Composer's autoloader 
$loader = require __DIR__.'/../vendor/autoload.php'; 

class AppKernel extends Kernel 
{ 
    use MicroKernelTrait; 

    public function registerBundles() 
    { 
     $bundles = array(
      new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), 
      new Symfony\Bundle\TwigBundle\TwigBundle(), 
      new Symfony\Bundle\MonologBundle\MonologBundle(), 
      new Symfony\Bundle\SecurityBundle\SecurityBundle(), 
      new DebatesBundle\DebatesBundle(), 
      new Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle(), 
      new FOS\UserBundle\FOSUserBundle(), 
      new Exten\FOSUserBundle\ExtenFOSUserBundle() 
     ); 

     if ($this->getEnvironment() == 'dev') { 
      $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); 
      $bundles[] = new \Symfony\Bundle\DebugBundle\DebugBundle(); 
     } 

     return $bundles; 
    } 

    protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader) 
    { 
     $loader->load(__DIR__ . '/config/config.yml'); 
     $loader->load(__DIR__.'/config/parameters.'.$this->getEnvironment().'.yml'); 

     // configure WebProfilerBundle only if the bundle is enabled 
     if (isset($this->bundles['WebProfilerBundle'])) { 
      $c->loadFromExtension('web_profiler', array(
       'toolbar' => true, 
       'intercept_redirects' => false, 
      )); 
     } 

     $loader->load(__DIR__.'/config/services.yml'); 
    } 

    protected function configureRoutes(RouteCollectionBuilder $routes) 
    { 

     $routes->import(__DIR__ . '/../src/DebatesBundle/Routes/routes.yml', '/', 'yaml'); 
     $routes->import('@FOSUserBundle/Resources/config/routing/all.xml', '/'); 

     // import the WebProfilerRoutes, only if the bundle is enabled 
     if (isset($this->bundles['WebProfilerBundle'])) { 
      $routes->import('@WebProfilerBundle/Resources/config/routing/wdt.xml', '/_wdt'); 
      $routes->import('@WebProfilerBundle/Resources/config/routing/profiler.xml', '/_profiler'); 
     } 
    } 

    // optional, to use the standard Symfony cache directory 
    public function getCacheDir() 
    { 
     return __DIR__ . '/cache/' .$this->getEnvironment(); 
    } 

    // optional, to use the standard Symfony logs directory 
    public function getLogDir() 
    { 
     return __DIR__ . '/logs'; 
    } 
} 
+0

您正在使用什么版本的Symfony?你可以发布你的composer.json吗? – mickadoo

+0

我正在尝试使用MicroKernel构建框架,就像本示例中的示例一样http://symfony.com/doc/current/configuration/micro_kernel_trait.html – PVN

+0

使用我的composer.json文件更新了说明。 – PVN

回答

3

固定的ER你报告的事情很简单。只需添加:

services: 
    validator.builder: 
    class: Symfony\Component\Config\Definition\Builder\ValidationBuilder 

要将services.yml

......然而,这并不解决了我的一切,并导致更多的问题与缺失的身份验证服务全部由FOS用户捆绑到来。我花了一段时间试图添加这些服务定义,但我认为内心有些问题。 FOSUserBundle没有支持Symfony 3的标签发布。你可以尝试在作曲家中使用dev-master,看看它是如何工作的,但它并没有为我解决它。

我的建议是首先尝试使用默认的Symfony3应用程序(不使用微内核),如果仍然无法确定您想要更多的Symfony3或FOSUserBundle。

+0

感谢您的帮助,它现在可行! – PVN

+0

很好,什么修正了它? – mickadoo

+0

我已经尝试从一个默认的Symfony3,同样的问题在那里:https://stackoverflow.com/questions/46217177/fosuser-on-symfon-3-3(因为这不是关于微内核,也许这个帖子会达到更多的人) – nicolallias

0

我解决我的问题与 services.yml:

Symfony\Component\Config\Definition\Builder\ValidationBuilder: 
    autowire: true 

按照documentation

你的情况如何?

相关问题