Symfony version basic 4.1.5.2
composer create-project symfony/website-skeleton sym01
php bin/console server:run
add the hidden folders or files
git add . git commit -m"first commit 🎉" git remote add NAME URL/GIT git push ori master
Procedurals actions
composer update
Frontal contoller: public/index.php
Models: src/Entity
Views: templates/
Controllers: src/Controller/
yaml => configuration
Routing => annotations
datas => json or other
php bin/console make:controller MyFirstController
creating
Your controller at
src/Controller/MyFirstController.php
and Your template at
templates/my_first/index.html.twig
in MyfirstController class with annotations
/**
* @Route("/", name="Accueil")
*/
public function accueilAction(){
// render the view
return $this->render('my_first/accueil.html.twig');
}
in templates/my_first create accueil.html.twig
{% extends 'base.html.twig' %}
{% block title %}Accueil{% endblock %}
{% block body %}
{% block titre %}Notre site{% endblock %}
{% block menu %}
<ul>
<li><a href="{{ path("Accueil") }}">Accueil</a></li>
<li><a href="{{ path("my_first") }}" title="Affichage de débugage de notre premier contrôlleur généré" target="_blank">my_first</a></li>
<li><a href=""></a></li>
</ul>
{% endblock %}
{% block contenu %}{% endblock %}
{% endblock %}