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

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 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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面