Symfony2 Demo configuration Failed

Source: Internet
Author: User
I want to add a page to access the link for/hello

The configuration steps are as follows:

1. Add the code in the app/appkernel.php file:

public function registerBundles() {$bundles[] = new Acme\HelloBundle\AcmeHelloBundle();return $bundles;}

2.app/config/routing.yml

acme_hello:  resource: "@AcmeHelloBundle/Resources/config/routing.yml"  prefix: /

3.src/acme/hellobundle/resources/config/routing.yml

hello:    pattern:  /hello/{name}    defaults: { _controller: AcmeHelloBundle:Hello:index }

4.src/acme/hellobundle/controller/hellocontroller.php

namespace Acme\HelloBundle\Controller;use Symfony\Component\HttpFoundation\Response;class HelloController {    public function indexAction()    {        return new Response("Hello World");    }}

I almost followed the documentation steps, but there were some problems:

Writing on the document to execute a command line can create a new bundle and generate a new bundle directory under the SRC/ACME directory, my execution is as follows:

D:\xampp\php>php d:\xampp\htdocs\Symfony\app\console --namespace=Acme/HelloBundle --format=yml

No effect, so I created it manually.

Reply content:

I want to add a page to access the link for/hello

The configuration steps are as follows:

1. Add the code in the app/appkernel.php file:

public function registerBundles() {$bundles[] = new Acme\HelloBundle\AcmeHelloBundle();return $bundles;}

2.app/config/routing.yml

acme_hello:  resource: "@AcmeHelloBundle/Resources/config/routing.yml"  prefix: /

3.src/acme/hellobundle/resources/config/routing.yml

hello:    pattern:  /hello/{name}    defaults: { _controller: AcmeHelloBundle:Hello:index }

4.src/acme/hellobundle/controller/hellocontroller.php

namespace Acme\HelloBundle\Controller;use Symfony\Component\HttpFoundation\Response;class HelloController {    public function indexAction()    {        return new Response("Hello World");    }}

I almost followed the documentation steps, but there were some problems:

Writing on the document to execute a command line can create a new bundle and generate a new bundle directory under the SRC/ACME directory, my execution is as follows:

D:\xampp\php>php d:\xampp\htdocs\Symfony\app\console --namespace=Acme/HelloBundle --format=yml

No effect, so I created it manually.

I have encountered an issue that caused YML parsing errors with tab. The first problem should be that the file format is not correct. The second question is that you namespace useless. The console should be Create:bundle commands with namespace and format.

Judging from the error message, it should be @acmehellobundle/resources/config/routing.yml this file, YAML syntax is not correct, to see if it is indented or knocked out non-English spaces and so on.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.