Answer the question
In order to leave comments, you need to log in
How to properly work with symfony/routing component?
I'm making a project from scratch, trying to set up routing with the symfony/routing component, as a result I get an empty page when I go to /blog
// congig/routing.php
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Route;
use App\Controller\BlogController;
$collection = new RouteCollection();
$collection->add('blog_list', new Route('/blog', array(
'_controller' => [BlogController::class, 'list']
)));
return $collection;
require '../vendor/autoload.php';
require '../config/routing.php';
namespace App\Controller;
class BlogController
{
/**
* Matches /blog exactly
*
* @Route("/blog", name="blog_list")
*/
public function list()
{
return phpinfo();
}
/**
* Matches /blog/*
*
* @Route("/blog/{slug}", name="blog_show")
*/
public function show($slug)
{
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question