Symfony installation error

0

I want to learn Symfony and then I did the installation as they speak on the site:

composer create-project symfony/framework-standard-edition meuprojeto/ '~2.5'

Until then I installed it, in the end I did not want to install the demo Acme and I made the settings, I entered the project folder, I ran the command:

php app/check.php 

And everything is OK, when I ran the command:

php app/console server:run 

I opened the address he had in my browser:

 http://127.0.0.1:8000

But it gives the errors:

  

Sorry, the page you are looking for could not be found. 2/2   NotFoundHttpException: No route found for "GET /" 1/2   ResourceNotFoundException:

Already tried to access:

127.0.0.1:8000/app_dev.php 

Also did not give, does anyone know how I can have a hello world ?

    
asked by anonymous 01.09.2014 / 16:43

3 answers

2

This error happens because you did not, in fact, define any routes mapped to / . If you had installed AcmeDemoBundle would have an initial route to exploit, which would be /hello/{name} .

The next step is to create a bundle within your Symfony application with the command app/console generate:bundle . Within this bundle there will be a Resources/config/routing.yml file in which you define the routes of your application, which will be mapped to actions in your controllers and that will eventually generate valid HTML responses to your requests.

    
04.09.2014 / 15:37
0

After a few more searches, I saw that this error was giving cause that it had nothing configured in routing.yml and so what I did was to create a sample page php app/console generate:bundle --namespace=Acme/DemoBundle --format=yml following this link link . I also added in composer.json, in the extra part of the following

"extra": {
    "symfony-app-dir": "app",
    "symfony-web-dir": "web",
    "symfony-assets-install": "symlink", // <- essa linha foi adicionada
    "incenteev-parameters": {
        "file": "app/config/parameters.yml"
    },
    "branch-alias": {
        "dev-master": "2.5-dev"
    }
}

I did this because after creating a demo page it started to make an error with the assets.

I hope it can help with future inquiries.

    
01.09.2014 / 18:48
0

Hello friend, Hello World is implemented in AcmeBundle. The No Route Found problem is because there is no route you want to access. I'll teach you the steps to create a new bundle and create a route for it.

Run the command:

php bin/console generate:bundle

Afterwards, it will ask you some questions about the name of the bundle, use annotation. After generating the bundle, it will have a DefaultController inside the Bundle. And the indexAction method that is auto-generated will have the @Route("/") path, which means that it is the root path of your server.

/** 
 * @Route("/")
 * @Method("GET")
 */
public function indexAction() {

}

HTML will be found in the Resources/views folder within the Bundle. The files will be inside the folder with the same name as the Bundle.

If you run Symfony server php bin/console server:run , you can access your project via the http://localhost:8000/ address and, as it is on the root route, it will open your indexAction .

If the route is:

/** 
 * @Route("/teste")
 * @Method("GET")
 */
public function indexAction() {

}

The address will be http://localhost:8000/teste . I hope I have helped!

    
16.02.2017 / 19:23