D
D
deleted-mezhevikin2011-07-30 16:40:35
symfony
deleted-mezhevikin, 2011-07-30 16:40:35

Creating a bundle in symfony2

1. Installed symfony2 downloaded from the office. site on denwer. ( localhost/app_dev.php/demo works)

2. I start following the instruction symfony.com/doc/2.0/book/page_creation.html .

2.1. In cmd I make a command to create a bundle:

D:\WebServers\usr\local\php5\php.exe D:\WebServers\home\akinator\www\Symfony\app\console generate:bundle --namespace=Acme/HelloBundle --format=yml


the folder with the files appeared Symfony\src\Acme\HelloBundle , and a new bundle was included in the app/AppKernel.php file .

2.2. I register routing:

# в app/config/routing.yml
AcmeHelloBundle:
    resource: "@AcmeHelloBundle/Resources/config/routing.yml"
    prefix:   /


# в src/Acme/HelloBundle/Resources/config/routing.yml
hello:
    pattern:  /hello/{name}
    defaults: { _controller: AcmeHelloBundle:Hello:index }


2.3. I create a file src/Acme/HelloBundle/Controller/HelloController.php and add the following code to it:

// src/Acme/HelloBundle/Controller/HelloController.php
namespace Acme\HelloBundle\Controller;

use Symfony\Component\HttpFoundation\Response;

class HelloController
{
    public function indexAction($name)
    {
        return new Response('<html><body>Hello '.$name.'!</body></html>');
    }
}


2.4. I request the page localhost/app_dev.php/hello/Ryan and see the following error: Question: What could be the problem, what am I doing wrong?



Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BoShurik, 2011-07-30
@BoShurik

What does route:debug output?
I suspect there is something like //helo/{name}.
It is necessary to remove "prefix: /".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question