Error at end of Symfony installation

Asked

Viewed 212 times

0

I’m willing to learn Symfony and then did the installation as they speak on the site:

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

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

php app/check.php 

And everything’s OK when I turn the remote:

php app/console server:run 

I opened in my browser the address he passed:

 http://127.0.0.1:8000

But make the mistakes:

Sorry, the page you are Looking for could not be found. 2/2 Notfoundhttpexception: No route found for "GET /" 1/2 Resourcenotfoundexception:

I’ve tried to access:

127.0.0.1:8000/app_dev.php 

Neither did it, does anyone know how I can have one hello world?

  • Is your php version 5.4+ ? Has apache installed?

  • Version php 5.5. * and apache ok

3 answers

2

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

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

0

Hi friend, Hello World is implemented in Acmebundle. The problem of "No route found" is because there is no route you want to access. I’ll teach you the steps to create a new Dark and create a route for it.

Run the command on the console:

php bin/console generate:bundle

After, he will ask questions about the Bundle name, use the Annotation. After generating the Bundle, he will have inside the Bundle a DefaultController. And the method indexAction which is automatically generated will take the route @Route("/"), this means it is the root route of your server.

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

}

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

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

If the route is:

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

}

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

0

After a few more searches, I saw that this error was giving because I had nothing configured on routing.yml and so what I did was create an example page php app/console generate:bundle --namespace=Acme/DemoBundle --format=yml following this link http://symfony.com/doc/current/book/page_creation.html . I also added in Composer.json , in the part of extra 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 it because after creating a demo page started to give error with the Assets.

I hope it can help for future consultations.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.