doutai1509
doutai1509
2014-06-24 07:33
浏览 67
已采纳

ERROR 4预期开始标记,未找到“<”(在n / a - 第1行,第1列)

I'm getting this error when I add a new service:

[ERROR 4] Start tag expected, '<' not found (in n/a - line 1, column 1)

This is the new services.yml file:

parameters:
    acme_foo.class: Acme\FooBundle\Services\Foos

services:
    acme_foo:
        class: %acme_foo.class%
        arguments: [@doctrine] 

There are no tabs in this file, only spaces. This is the DependencyInjection/Configuration.php file:

<?php

namespace Acme\FooBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
 * This is the class that validates and merges configuration from your app/config files
 *
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
 */
class Configuration implements ConfigurationInterface
{
    /**
     * {@inheritDoc}
     */
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root('acme_foo');

        // Here you should define the parameters that are allowed to
        // configure your bundle. See the documentation linked above for
        // more information on that topic.

        return $treeBuilder;
    }
}

and the DependencyInjection/AcmeFooExtension.php:

<?php

namespace Acme\FooBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;

/**
 * This is the class that loads and manages your bundle configuration
 *
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
 */
class RedconviveSubscriptionExtension extends Extension
{
    /**
     * {@inheritDoc}
     */
    public function load(array $configs, ContainerBuilder $container)
    {
        $configuration = new Configuration();
        $config = $this->processConfiguration($configuration, $configs);

        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load('services.yml');
    }
}

Any idea of where the error is? It seems to be related to services.yml, but I've checked it and doesn't seem to be there.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dswmmvrg40957
    dswmmvrg40957 2014-06-24 07:38
    已采纳

    Change

    $loader = new Loader\XmlFileLoader
    

    to

    $loader = new Loader\YamlFileLoader
    

    in DependencyInjection/AcmeFooExtension.php. Because you are loading yml file.

    点赞 评论

相关推荐