gpt4 book ai didi

php - 错误 4 预期开始标记,未找到 '<'(在 n/a - 第 1 行,第 1 列)

转载 作者:行者123 更新时间:2023-12-05 09:22:55 27 4
gpt4 key购买 nike

我在添加新服务时遇到此错误:

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

这是新的 services.yml 文件:

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

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

此文件中没有制表符,只有空格。这是 DependencyInjection/Configuration.php 文件:

<?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;
}
}

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');
}
}

知道错误在哪里吗?好像和services.yml有关,我查了一下好像没有。

最佳答案

改变

$loader = new Loader\XmlFileLoader

$loader = new Loader\YamlFileLoader

DependencyInjection/AcmeFooExtension.php 中。因为你正在加载 yml 文件。

关于php - 错误 4 预期开始标记,未找到 '<'(在 n/a - 第 1 行,第 1 列),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24380858/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com