No route found for "GET https://localhost:8000/conference" #51515
-
Hi, I'm at the step regarding creating a new controller., so I did Then I tried to open The controller looks like this: <?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class ConferenceController extends AbstractController
{
#[Route('/conference', name: 'app_conference')]
public function index(): Response
{
return $this->render('conference/index.html.twig', [
'controller_name' => 'ConferenceController',
]);
}
} I tried to clear cache and restart server, nothing worked. Finally I found somewhere (not in the book itself, and actually the problem was different): This created this file: "config/routes/annotations.yaml" which looks like this: controllers:
resource: ../../src/Controller/
type: annotation
kernel:
resource: ../../src/Kernel.php
type: annotation And... it worked. But why? I mean - Why did I have to do this, and what does 'annotations' from Doctrine have to do with routing in Symfony? This book was supposed to guide me step by step into the intricacies of Symfony, and yet I got stuck on such a simple step :( BTW, I know there is a book for 6.2 but I am supposed to learn 5.4. It's not that old AFAIK. I'm on the verge of madness... this is my second attempt with Symfony, and also my second with the book "The Fast Track," |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Have a look at https://symfony.com/doc/5.4/routing.html. As for Symfony project references, you can take a look at the Symfony Demo Project. It can help a lot! Check also SymfonyCast tutorials |
Beta Was this translation helpful? Give feedback.
-
Thanks @cavasinf ! OK, I will read the docs, and yeah - those SymfonyCasts are a cool source as well. But - I believe this thing (installing annotations with composer) should be mentioned in the book (since it tells us to use them). I had a strong impression that the book is incomplete, and I'll soon encounter some more weird issues :) I'm a Symfony beginner, that is why for me it wasn't easy to solve it. Nevertheless - thanks again! These SymfonyCasts look like a very effective way to learn SF. |
Beta Was this translation helpful? Give feedback.
Have a look at https://symfony.com/doc/5.4/routing.html.
Note that depending on PHP7 OR PHP8 you will have a different composer/config.
Since PHP7 is EOL, read the
attributes
sections.As for Symfony project references, you can take a look at the Symfony Demo Project. It can help a lot!
Check also SymfonyCast tutorials