2014-07-14 1 views
0

에 내 번들을 만들려고합니다. 이 튜토리얼에서는 "Acme"번들을 만드는 과정을 안내합니다. Acme Demo 번들과 함께 제공된 심포니 2.4를 다운로드 한 이래로. 모든 "AcmeBundle"을 "myAcmeBundle"로 변경했습니다. 나는 번들의 이름을 제외하고 명령과 정확히 같은 컨트롤러, 라우트 및 번들을 생성했다.symfony 어느 번들을 실행하고 있습니까

혀를 내가

http://localhost/app_dev.php/hello/Ryan 

에 가면 내 질문 심포니 번들되는 알고 어떻게 실행할 것입니다 내 HelloController.php 를 호출 할 필요가 있다고 말한다. 내 "src"폴더에 2 번들이 있습니다. localhost/app_dev.php/hello/Ryan을 입력하면 HelloController.php의 내용이 AcmeBundle (기본 데모 번들)에 표시됩니다. HelloController.php의 내용을 myAcmeBundle (내 새로 만든 번들)에 표시하고 싶습니다.

추가 정보 : 클래스 AppKernel과 관련이있다 어쩌면 무언가하지만, 아주 확실하지

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 myAcme\HelloBundle\myAcmeHelloBundle(), 
     ); 

     if (in_array($this->getEnvironment(), array('dev', 'test'))) { 
      $bundles[] = new Acme\DemoBundle\AcmeDemoBundle(); 
      //$bundles[] = new myAcme\HelloBundle\myAcmeHelloBundle(); 
      $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(__DIR__.'/config/config_'.$this->getEnvironment().'.yml'); 
    } 
} 

응용 프로그램 \ 설정 \ routing.yml SRC

my_acme_hello: 
    resource: "@myAcmeHelloBundle/Resources/config/routing.yml" 
    prefix: /

\ myAcme \ HelloBundle \ Resources \ config \ routing.yml

my_acme_hello_homepage: 
    path:  /hello/{name} 
    defaults: { _controller: myAcmeHelloBundle:Default:index } 
+0

의 "안녕하세요"컨트롤러 라우팅 설정 [this] (http://symfony.com/doc/current/book/routing.html) 페이지를 읽었습니까? – bzeaman

+0

'src/Acme/HelloBundle/Resources/config/routing.yml'에서 라우팅 항목을 제거 했습니까? 먼저 일치하는 것이 발견되면 컨트롤러를 선택하는 데 사용됩니다. – bzeaman

답변

0

전화 대신 "기본"컨트롤러 당신은 조정할 필요가

my_acme_hello_homepage: 
    path:  /hello/{name} 
    defaults: { _controller: myAcmeHelloBundle:Hello:index } 
1

Symfony2 경로는 제공됩니다. d (매치)가 파싱 된 순서와 같습니다 : prefix: /을 사용할 때 (특별히 test hello ruote) 다른 곳을 지정하지 않으면 AcmeBundle 경로를 덮어 쓰려고합니다. enaugh 정보가 없어도 상상할 수 있습니다. 번들 경로.

해결책 : 잠시 후 AcmeBundle의 등록을 취소하고 어떤 현상이 나타나는지보십시오. 이제 프레임 워크는 당신의 newbundle RUOTE를 제공하고 살아 AcmeBundle을 유지하려면 다음과 같이 , 당신은 당신의 AppKernel을 수정

업데이트

이 AcmeDemoBundle 등록을 취소하기 AcmeDemo 것들 전에 번들의 노선을 작성해야 :

if (in_array($this->getEnvironment(), array('dev', 'test'))) { 
    //$bundles[] = new Acme\DemoBundle\AcmeDemoBundle(); 
    $bundles[] = new myAcme\HelloBundle\myAcmeHelloBundle(); 
    $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); 
    $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle(); 
    $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); 
} 
+0

안녕하세요, 저는 심포니를 처음 사용합니다. 번들 등록을 해제하는 방법? – kaboom

+0

@kaboom : 내 업데이트 참조 – DonCallisto

관련 문제