Components

วาง UI ชิ้นส่วนที่นำกลับใช้ได้ใน components/ แล้ว include ใน layout หรือ page.

ตัวอย่างการ include ใน layout

<?php include(__DIR__ . "/../components/navbar.php"); ?>

ตัวอย่างการ include ใน page

ถ้าไฟล์อยู่ใน pages/foo/bar.php ให้ใช้ path ย้อนขึ้นไปยังรากโปรเจกต์ก่อน แล้วค่อยไปโฟลเดอร์ components/.

<?php
// ใน pages/foo/bar.php
include __DIR__ . "/../../components/your-component.php";
?>