دورة SYMFONY 4 للمبتدئين الدرس الثاني
1- عرض جميع les routes لي عندنا
//
php bin/console debug:router
2- إضافة صفحة جديدة
//
hello from hello page
3- عرض محتوى الملف hello.html.twig
//
<?php
namespace App\Controller;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class HelloController extends AbstractController
{
/**
* @Route("/hello")
*/
public function index()
{
// return new Response(
// '<html><body>Hello World</body></html>'
// );
return $this->render('hello.html.twig');
}
}
4- عرض variable فالصفحة hello.html.twig
//
<?php
namespace App\Controller;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class HelloController extends AbstractController
{
/**
* @Route("/hello")
*/
public function index()
{
// return new Response(
// '<html><body>Hello World</body></html>'
// );
$sayHello = "hello world from hello page";
return $this->render('hello.html.twig',[
'hello' => $sayHello
]);
}
}
5- عرض variable فالصفحة hello.html.twig تتمة
//
{{hello}}