S
S
svd2222017-10-26 13:00:17
symfony
svd222, 2017-10-26 13:00:17

Symfony 3: How to properly create a route (via annotations) to make it work?

1) I create a new project according to the documentation symfony.com/doc/current/setup.html

composer create-project symfony/framework-standard-edition my_project_name
composer install, update, e.t.c

In the controller AppBundle\Controller\DefaultController I add the method:
/**
     * @Route("/any", name="any")
     * @Method("GET")
     */
    public function anyAction()
    {
        return new Response("i`am loaded for test");
    }

I go to project/any and get a 404 error.
2) I install symfony demo app: I
composer create-project symfony/symfony-demo
repeat the steps described above (in AppBundle\Controller\BlogController), everything works.
The nginx settings for both cases are the same.
I read the doc on routes several times https://symfony.com/doc/current/routing.html The
question is, what am I doing wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
BoShurik, 2017-10-26
@BoShurik

Apparently you are trying to enter the page through the prod environment, and clear the cache - for dev
Try
project/app_dev.php/any
Or
php bin/console cache:clear --no-warmup --env=prod

S
svd222, 2017-10-26
@svd222

PS
does not give any errors, displays the specified route
clearing the cache
does not help.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question