Symfony2Demo configuration failed

Source: Internet
Author: User
To add a page, follow these steps to access the link "hello": 1. in appAppKernel. add code to the PHP file: {code ...} 2. appconfigrouting. yml {code ...} 3. srcAcmeHelloBundleResourcesconfigrouting. yml {code ...} 4 .... I want to add a page with the access link/hello

The configuration steps are as follows:

1. add the code to 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 steps in the document, but there are still some problems:

Cannot import resource "D:/xampp/htdocs/Symfony/app/config\routing.yml" from "D:/xampp/htdocs/Symfony/app/config/routing_dev.yml". (Unable to parse at line 2 (near "resource:"@AcmeHelloBundle/Resources/config/routing.yml"").) 

You can create a new bundle and create a new bundle directory under the src/Acme directory:

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 with the access link/hello

The configuration steps are as follows:

1. add the code to 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 steps in the document, but there are still some problems:

Cannot import resource "D:/xampp/htdocs/Symfony/app/config\routing.yml" from "D:/xampp/htdocs/Symfony/app/config/routing_dev.yml". (Unable to parse at line 2 (near "resource:"@AcmeHelloBundle/Resources/config/routing.yml"").) 

You can create a new bundle and create a new bundle directory under the src/Acme directory:

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 the yml parsing error caused by using tabs. The first problem is that the file format is incorrect. The second problem is that it is useless to add a namespace. In the console, it should be the create: bundle command followed by namespace and format.

Judging from the error information, the yaml syntax in the file @ AcmeHelloBundle/Resources/config/routing. yml is incorrect. check whether the file is indented or contains non-English spaces.

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.