I am trying to create my first bundle in Symfony. The tutorial walks you through the process of creating a bundle called "Acme". Since I downloaded symfony 2.4 that went with the Acme Demo bundle. I changed all "AcmeBundle" to "myAcmeBundle". I created the controller, the route and the bundle exactly like the instruction except the name of the bundle.
The tut says that if I go to
http://localhost/app_dev.php/hello/Ryan
it should invoke my HelloController.php My question is that how symfony knows which bundle I want to run. I have 2 bundles in my "src" folder now. and whenever I enter localhost/app_dev.php/hello/Ryan , it displays the content of HelloController.php in AcmeBundle (the default demo bundle). I want to display the content of HelloController.php in myAcmeBundle (my new created bundle).
Additional info: maybe something that has to do with the class AppKernel, but not very sure
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');
}
}
app\config\routing.yml
my_acme_hello:
resource: "@myAcmeHelloBundle/Resources/config/routing.yml"
prefix: /
src\myAcme\HelloBundle\Resources\config\routing.yml
my_acme_hello_homepage:
path: /hello/{name}
defaults: { _controller: myAcmeHelloBundle:Default:index }
src/Acme/HelloBundle/Resources/config/routing.yml
? Whichever match is found first will be used to select a controller. – bzeaman