[php] “AsseticBundle 구성에 myBundle 추가”symfony2 예외를 수정하려면 어떻게해야합니까?

TWIG {% javascript %}태그 를 사용하여 내 .js파일 에 연결 하려고 할 때 다음 예외와 함께 반환됩니다.

An exception has been thrown during the compilation of a template ("You must add CompetitiongameBundle to the assetic.bundle config to use the {% javascripts %} tag in CompetitiongameBundle:game:index.html.twig.") in "CompetitiongameBundle:game:index.html.twig".

index.html.twig외모 :

{% javascripts 'CompetitiongameBundle/Resources/views/public/js/*'%}
    <script type="text/javascript" src="{{ asset_url }}" ></script>
{% endjavascripts %}
Hello {{ name }}!

<a href='{{ nexturl }}' >Login</a>

내 번들은 내가 할 때 이미 구성 파일에 있습니다.

php app/console config:dump-reference assetic

이 문제를 어떻게 해결할 수 있습니까?



답변

예, 나는 시도했고 그것은 나를 위해 문제를 해결했습니다. 처음에 추가하는 방법을 모르는 사람 (나와 같은)의 경우 :

  1. 편집하다 app/config/config.yml
  2. 다음으로 이동 assetic:
  3. 자산 아래 : 이동 bundles: []
  4. 과에 bundles: []// 당신의 번들 이름을 입력

예를 들어 번들이 인 Acme\DemoBundle경우 다음을 수행하십시오.

assetic:
   bundles: [ AcmeDemoBundle ]

주위에 따옴표가 없습니다 AcmeDemoBundle. 그게 다야. (심포니 2)


답변

Assetic에 기본적으로 번들이 포함되도록하려면 줄에 주석 (# 사용)을 할 수 있습니다. bundles: []

전의:

assetic:
    debug:          "%kernel.debug%"
    use_controller: false
    #bundles:        [ ]
    #java: /usr/bin/java


답변

때때로 즉시 결정을 내려야 할 때 DependencyInjection을 사용할 수 있습니다 .

예를 들어 구성로드하고 관리 하려면 :

<?php

namespace You\ExampeBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;

/* ... */

class YouExampeExtension extends Extension
{

    /* ... */

    public function load(array $configs, ContainerBuilder $container)
    {
        /* ... */

        $aAsseticBundle = $container->getParameter('assetic.bundles');
        $aAsseticBundle[] = 'YouExampeBundle';
        $aAsseticBundle[] = 'AnotheBundle';
        $container->setParameter('assetic.bundles', $aAsseticBundle);

        /* ... */
    }
}

더 복잡한 논리를 사용하여 구성을 조작 할 수 있습니다 (적당한 제한 내에서)


답변

번들에 번들을 추가해야합니다. app / config / config.yml 파일의 [] assetic : 섹션 행 (symfony 2.1)


답변