【问题标题】:Symfony2.0 - InvalidArgumentExceptionSymfony2.0 - InvalidArgumentException
【发布时间】:2014-01-14 09:46:03
【问题描述】:

我在使用 symfony 2.3 时遇到了一点问题,希望您能帮帮我。

我真的不知道我做错了什么,但突然间我得到了这些错误,现在我无法摆脱它们。

错误 1:

InvalidArgumentException: [WARNING 1549] failed to load external entity "file:///C:/wamp/www/Symfony/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd" (in n/a - line 0, column 0)
[WARNING 3084] Element '{http://www.w3.org/2001/XMLSchema}import': Failed to locate a schema at location 'file:///C:/wamp/www/Symfony/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd'. Skipping the import. (in in_memory_buffer - line 8, column 0)
[ERROR 1845] Element '{http://symfony.com/schema/dic/services}container': No matching global declaration available for the validation root. (in file:///C:/wamp/www/Symfony/web/ - line 5, column 0)

错误2:

InvalidArgumentException: Unable to parse file "C:\wamp\www\Symfony\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\DependencyInjection/../Resources/config\web.xml".

我已尝试删除我认为导致这些错误的原因(我也尝试清理缓存),但没有任何效果。

我猜我在 twig 或 xlf 文件中一定有问题,因为这些错误出现在我只修改了这些文件之后,但无法找出我在这些文件中做错了什么(对我来说我所做的看起来不错)

如果你们需要,我可以发布文件。

编辑:

树枝文件:

{%  extends '::base.html.twig' %}

{% block title %}{{ 'myAccount'|trans }}{% endblock %}
{% block stylesheets %}
    {{ parent() }}
    <link href="{{ asset('bundles/account/css/myProfile.css') }}" rel="stylesheet">
{% endblock %}
{% block content %}
<div class="profile-hor-nav">
    <ul class="nav nav-pills profile-menu-font">
        <li class="active profile-hor-nav-element">
            <a href="#">{{ 'gameInfo'|trans }}</a>
        </li>
        <li class="profile-hor-nav-element">
            <a href="#">{{ 'accountInfo'|trans }}</a>
        </li>
    </ul>
</div>
<div class="profile-ver-nav">
    <ul class="nav nav-pills nav-stacked profile-menu-font">
        <li class="active profile-ver-nav-element">
            <a href="#">{{ 'matchHistory'|trans }}</a>
        </li>
        <li class="profile-ver-nav-element">
            <a href="#">{{ 'statistics'|trans }}</a>
        </li>
        <li class="profile-ver-nav-element">
            <a href="#">{{ 'charObj'|trans }}</a>
        </li>
    </ul>
</div>
{% endblock %}

en.xlf:

<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
    <file source-language="en" datatype="plaintext" original="file.ext">
        <body>
            <trans-unit id="1">
                <source>registrationMessage</source>
                <target>Enroll and fight for glory on the battlefields.</target>
            </trans-unit>
            <trans-unit id="2">
                <source>registrationSuccessMessage</source>
                <target>You will receive an email to finish your registration</target>
            </trans-unit>
            <trans-unit id="3">
                <source>gameInfo</source>
                <target>Game information</target>
            </trans-unit>
            <trans-unit id="4">
                <source>accountInfo</source>
                <target>Account information</target>
            </trans-unit>
            <trans-unit id="5">
                <source>matchHistory</source>
                <target>Match history</target>
            </trans-unit>
            <trans-unit id="6">
                <source>statistics</source>
                <target>Statistics</target>
            </trans-unit>
            <trans-unit id="7">
                <source>charObj</source>
                <target>Characters and Objects</target>
            </trans-unit>
        </body>
    </file>
</xliff>

fr.xlf:

<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
    <file source-language="en" datatype="plaintext" original="file.ext">
        <body>
            <trans-unit id="1">
                <source>registrationMessage</source>
                <target>Inscrivez-vous et combattez pour la gloire sur les champs de bataille.</target>
            </trans-unit>
            <trans-unit id="2">
                <source>registrationSuccessMessage</source>
                <target>Vous allez recevoir un email pour completer votre inscription</target>
            </trans-unit>
            <trans-unit id="3">
                <source>gameInfo</source>
                <target>Informations en jeu</target>
            </trans-unit>
            <trans-unit id="4">
                <source>accountInfo</source>
                <target>Informations du compte</target>
            </trans-unit>
            <trans-unit id="5">
                <source>matchHistory</source>
                <target>Historique des parties</target>
            </trans-unit>
            <trans-unit id="6">
                <source>statistics</source>
                <target>Statistiques</target>
            </trans-unit>
            <trans-unit id="7">
                <source>charObj</source>
                <target>Personnages et Objets</target>
            </trans-unit>
        </body>
    </file>
</xliff>

编辑 2:

所以查了一下,我其实有symfony的2.4.0 BETA1版本

我正在使用 apache 2.4.4、php 5.4.16 和 mysql 5.6.12 运行 wampserver

希望你能帮助我,

提前感谢您的帮助。

【问题讨论】:

  • 我已尝试删除我认为导致这些错误的原因 - 你到底删除了什么?
  • 只是我在 twig 和 xlf 文件中添加的内容...
  • 我会在稍后发布这些文件
  • 您真的清理过缓存吗?您可以只删除缓存文件夹(不是缓存文件夹本身,只删除其中的文件夹)。您介意发布您的完整设置(版本、网络服务器等)吗?\
  • 我使用了 php app/console cache:clear 命令(开发模式)。我会编辑我的帖子并添加您现在要求的内容

标签: symfony symfony-2.3 invalidargumentexception


【解决方案1】:

我不知道为什么,但是在重新启动计算机(wampserver 也是如此)之后,问题就消失了。 如果你们知道为什么会这样,我会很高兴听到的。

【讨论】:

  • 首先,我不相信这会奏效。看起来很愚蠢,但是当我尝试时它确实有效! :P
【解决方案2】:

我也遇到过类似的错误,而且很简单。

您的问题可能出在您的 dependencyInjection Bundle 中使用的扩展中。 就我而言,我正在使用 xmlFileLoader 加载 yml 文件,如下所示:

<?php

namespace xxx\UserBundle\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 xxxUserExtension 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('user.yml');
        $loader->load('forms.yml');               
    }
}

我正在加载 yml 文件,因此我不得不使用 YmlFileLoader 而不是 XmlFileLoader。

更多信息在这里:https://creativcoders.wordpress.com/2014/06/19/symfony2-symfonycomponentdependencyinjectionexceptioninvalidargumentexception-unable-to-parse-file/

【讨论】:

    猜你喜欢
    • 2017-12-18
    • 1970-01-01
    • 2012-09-11
    • 2016-05-17
    • 2018-08-16
    • 1970-01-01
    • 1970-01-01
    • 2013-04-27
    • 1970-01-01
    相关资源
    最近更新 更多