A code along through Symfonycasts Learn Symfony track.
- The base
symfony/skeleton
install is essentially a small route-controller system. The routes are defined atconfig/routes.yaml
and the controllers reside at thesrc/Controller
directory. - An alternative routing method is to use the
Symfony\Component\Routing\Annotation\Route
annotation and define the route alongside the controller.
class ArticleController
{
/**
* @Route("/")
*
* @return Response
*/
public function homepage()
{
return new Response('hello, world!');
}
}
- The router also supports wildcards like:
class ArticleController
{
...
/**
* @Route("/news/{slug}")
*
* @param $slug
*
* @return Response
*/
public function show(string $slug)
{
return new Response('The slug is: '.$slug);
}
}
-
The Symfony Flex system is a tool for installing related packages. The system gives packages an alias (like
annotations
fordoctrine/annotations
) and a recipe which triggers actions after installing the said package. -
Symfony uses (by default) Twig as its templating system. The docs are straightforward so go read that one. It looks and feels like Jinja!
Released under the MIT License