-4

I'm really struggling starting with Symfony 3. I made a first project, http://triod.ru/project/web/ and tried to make another page using the official tutorial http://symfony.com/doc/current/book/page_creation.html and made a file LuckyController.php in src/AppBundle/Controller directory, but it doesn't work. There is no page /lucky/number on the site.

  • "It does not work" is not a good error description. Always ask yourself "would I be be able to investigate an error with this description" before posting your question. Please show us at least your configs and controller – Jojo Mar 19 '16 at 12:21
  • I'm sorry. the system is in dev mode, I thought it can give you any information that you need. The problem is that Symphony is a black box for me. I do exactly as in the official tutorial and it just doesn't work. I have no idea why. – Vladimir Shevelyov Mar 19 '16 at 12:51
  • still, put some effort in explaining what you did. For example: "I do exactly as in the tutorial". For sure, you made something before following the page-creation turorial, for example installing symfony and creating your project in the first place. How? – Jojo Mar 19 '16 at 13:35
  • Tbh, I just asked a hoster to install a Symfony. That's all. Then I changed the "prod" to "dev" in app.php file. And then I made a file src/AppBundle/Controller/LuckyController.php with the code exactly the same as here http://symfony.com/doc/current/quick_tour/the_big_picture.html That's it. I'm really sorry for my pity description. – Vladimir Shevelyov Mar 19 '16 at 14:00
  • the tutorial you are linking to says: "Before continuing, make sure you've read the Installation chapter and can access your new Symfony app in the browser." You have issues with the routing (http://symfony.com/doc/current/book/routing.html), the interesting configs are app/config/routing.yml|xml|php and src/AppBundle/Resources/config/routing.yml|xml|php. You seriously need get a basic understanding on how symfony works. This will enable youat least to know what you ask about. – Jojo Mar 19 '16 at 14:09
  • I can access the homepage http://triod.ru/project/web/ but I can't access any others. I just need some working example, nothing more. Why would be the problem with configs if nobody didn't change them since the installation? I have a /lucky/number in the url, I have a /** * @Route("/lucky/number") */ in the controller The documentation says it is enough. – Vladimir Shevelyov Mar 19 '16 at 14:21
  • Can you post your entire LuckyController.php file please? – mferly Apr 02 '16 at 19:47
  • Took me a while to find the proper answer, this one worked http://stackoverflow.com/questions/36105001/symfony-3-simple-route-dosnt-work –  May 18 '16 at 22:32

2 Answers2

0

You should do php app\console cache:clear --env=prod or php bin\console cache:clear --env=prod in your symfony directory. Make sure that you 'use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;' in your lucky controller.

zeljkoMON
  • 23
  • 5
  • I don't really want in it prod mode, I want it in to dev mode so far. Sure I use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; It still doesn't work( – Vladimir Shevelyov Mar 19 '16 at 12:49
0

Php file must always be in a <?php?> processing instruction. If you just copy and paste it, the example lacks <?php at the beginning of the file and ?> at the end. If you add those, the route will work.

Put <?php at the beginning of the file and ?> at the end of the LuckyController.php file

Toby Speight
  • 27,591
  • 48
  • 66
  • 103
Solomon Tesfaye
  • 186
  • 2
  • 10