Direction Régionale Rabat – Salé - Kénitra
Année de Formation 2022/2023
M205 : Développer en back end
TP : Gestion de Routage
Créer un nouveau projet Laravel : TPRoutes
Syntaxe :
………………………………………………………………………………………………………..
Quelle sont les fichiers qui contient le dossier Routes ?
Quelle sont les catégories de routage utiliser par Laravel ?
Routage de base
1) Ajouter une route qui permet de retourner le message ‘Bonjour Laravel’ ?
(http://127.0.0.1:8000/home)
Syntaxe :
………………………………………………………………………………………………………..
………………………………………………………………………………………………………..
………………………………………………………………………………………………………..
2) Créer une vue avec le nom accueil.blade.php dans le dossier /resource/views qui permet
d’afficher le titre Accueil?
3) Ajouter une route qui permet de router la vue ‘accueil’ ?
(http://127.0.0.1:8000/accueil)
Syntaxe :
………………………………………………………………………………………………………..
………………………………………………………………………………………………………..
………………………………………………………………………………………………………..
4) Créer un contrôleur avec le nom TestController
Syntaxe :
………………………………………………………………………………………………………..
Belyazidi hamid Page 1 / 3
5) Ajouter au contrôleur TestController une méthode index qui retourne un message ‘je suis le
contrôleur TestController’
Syntaxe :
………………………………………………………………………………………………………..
………………………………………………………………………………………………………..
………………………………………………………………………………………………………..
6) Ajouter une route qui permet de router la méthode index du Contrôleur TestController ?
(http://127.0.0.1:8000/test)
Syntaxe :
………………………………………………………………………………………………………..
………………………………………………………………………………………………………..
………………………………………………………………………………………………………..
7) Ajouter au contrôleur TestController une autre méthode show qui retourne la vue ‘accueil’
Syntaxe :
………………………………………………………………………………………………………..
………………………………………………………………………………………………………..
………………………………………………………………………………………………………..
8) Ajouter une route qui permet de router la méthode show du Contrôleur TestController ?
(http://127.0.0.1:8000/test)
Syntaxe :
………………………………………………………………………………………………………..
………………………………………………………………………………………………………..
………………………………………………………………………………………………………..
Si on change dans le fichier /routes/web.php l’ordre de la route sur la méthode index avec la
route qui pointe sur la méthode sur show.
9) Quelle sera le résultat du lien ?
(http://127.0.0.1:8000/test)
10) Ajouter une route qui permet de router la vue ‘accueil’’ en utilisant le view route ?
(http://127.0.0.1:8000/view)
Syntaxe :
………………………………………………………………………………………………………..
………………………………………………………………………………………………………....
Belyazidi hamid Page 2 / 3
Routes nommées
1) Nommer la route qui permet de router la vue ‘accueil’’ avec le nom accueil?
(http://127.0.0.1:8000/accueil)
Syntaxe :
………………………………………………………………………………………………………..
………………………………………………………………………………………………………..
………………………………………………………………………………………………………..
2) Créer une vue avec le nom test.blade.php dans le dossier /resource/views qui contient un
lien hypertexte vers la vue Accueil ?
Syntaxe :
………………………………………………………………………………………………………..
………………………………………………………………………………………………………..
………………………………………………………………………………………………………..
Paramètres de Route
1) Ajouter une route qui permet de retourner le message ‘Bonjour Yahya’ ?
(http://127.0.0.1:8000/home/Yahya)
Syntaxe :
………………………………………………………………………………………………………..
………………………………………………………………………………………………………..
………………………………………………………………………………………………………..
2) Modifier la route pour retourner le message ‘Bonjour Ritaje votre Age est 7 ans’ ?
(http://127.0.0.1:8000/home/Ritaje/7)
Syntaxe :
………………………………………………………………………………………………………..
………………………………………………………………………………………………………..
………………………………………………………………………………………………………..
3) Modifier la route pour retourner le message ‘Bonjour Ritaje votre Age est 7 ans’ pour les
deux cas suivants ? (http://127.0.0.1:8000/home/Ritaje/7) ou
(http://127.0.0.1:8000/home/Ritaje)
Syntaxe :
………………………………………………………………………………………………………..
………………………………………………………………………………………………………..
………………………………………………………………………………………………………..
Belyazidi hamid Page 3 / 3