2015-09-13 42 views
0

我有兩個項目,我回到開發第一個項目。在創建第二個之前,一切都很好。現在,當我啓動此功能:爲什麼Symfony從不同的項目呈現捆綁包?

/** 
* @Route("/admin", name="admin_page") 
*/ 

public function indexAction() 
{ 

    return $this->render('DevTaskBundle:User:login.html.twig'); 
} 

我看到的第二個項目捆綁相關的錯誤:

An exception has been thrown during the compilation of a template 
("Bundle "GradeBundle" does not exist or it is not enabled. 
Maybe you forgot to add it in the registerBundles() method of your 
AppKernel.php file?") in "DevTaskBundle:User:login.html.twig". 

這是怎麼回事?如何解釋這一點? GradeBundle在第二個項目中。這是我有這種錯誤的唯一功能。其他工作很好,因爲他們是。我在這個項目中從未有過GradeBundle。

這是AppKernel.php

<?php 

use Symfony\Component\HttpKernel\Kernel; 
use Symfony\Component\Config\Loader\LoaderInterface; 

class AppKernel extends Kernel 
{ 
    public function registerBundles() 
    { 
     $bundles = array(
      new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), 
      new Symfony\Bundle\SecurityBundle\SecurityBundle(), 
      new Symfony\Bundle\TwigBundle\TwigBundle(), 
      new Symfony\Bundle\MonologBundle\MonologBundle(), 
      new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), 
      new Symfony\Bundle\AsseticBundle\AsseticBundle(), 
      new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), 
      new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), 
      new Dev\TaskBundle\DevTaskBundle(), 

     ); 

     if (in_array($this->getEnvironment(), array('dev', 'test'))) { 
      $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle(); 
      $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); 
      $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle(); 
      $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); 
     } 

     return $bundles; 
    } 

    public function registerContainerConfiguration(LoaderInterface $loader) 
    { 
     $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml'); 
    } 
} 

模板login.html.twig

<!DOCTYPE html> 
<html> 
<head> 
<title>{% block title %}Hello{% endblock %}</title> 
{% block stylesheets %} 
     <link href="{{ asset('bundles/devtask/css/stylesheet.css') }}" type="text/css" rel="stylesheet" /> 
     <link href="{{ asset('bundles/devtask/css/bootstrap.css') }}" type="text/css" rel="stylesheet" /> 
    {% endblock %} 
</head> 

{% block body -%} 
<body class="fullBody"> 




<div class="panelContener"> 
<form action="{{ path('login_route') }}" method="post"> 
    <div class="form-group"> 
    <label for="username">Username:</label> 
    <input type="text" id="username" name="name" style="color:black;"/> 
</div> 
<div class="form-group"> 
    <label for="password">Password:</label> 
    <input type="password" id="password" name="pass" style="color:black;" /> 
</div> 

     <input type="hidden" name="_target_path" value="/account" /> 

    <button type="submit" style="color:black;">login</button> 
</form> 
</div> 

{% javascripts 
'@GradeBundle/Resources/public/js/*' 
'@GradeBundle/Resources/public/js/bootstrap.js' 
'@GradeBundle/Resources/public/js/jquery-2.1.4.js' 
%} 
    <script src="{{ asset_url }}"></script> 
{% endjavascripts %} 

</body> 
    {% endblock %} 
</html> 
+0

包括你的模板 – user2268997

回答

0

您要求從GradeBundle資產在你的模板文件。因此,該應用程序將嘗試訪問@GradeBundle資源。由於GradeBundle包未註冊到內核,因此無法解析@GradeBundle/Resources/...路徑。