Man*_*olo 2 php service symfony
我添加新服务时收到此错误:
[ERROR 4]期望开始标记,未找到"<"(在n/a - 第1行,第1列)
这是新services.yml文件:
parameters:
acme_foo.class: Acme\FooBundle\Services\Foos
services:
acme_foo:
class: %acme_foo.class%
arguments: [@doctrine]
Run Code Online (Sandbox Code Playgroud)
此文件中没有选项卡,只有空格.这是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;
}
}
Run Code Online (Sandbox Code Playgroud)
和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');
}
}
Run Code Online (Sandbox Code Playgroud)
知道错误在哪里?它似乎与之相关services.yml,但我已经检查过它,似乎并不存在.
更改
$loader = new Loader\XmlFileLoader
Run Code Online (Sandbox Code Playgroud)
至
$loader = new Loader\YamlFileLoader
Run Code Online (Sandbox Code Playgroud)
在DependencyInjection/AcmeFooExtension.php.因为你正在加载yml文件.
| 归档时间: |
|
| 查看次数: |
1719 次 |
| 最近记录: |