DLight Docs PHP 8+
Version: 20260401-dev

Giới thiệu DLight

DLight là framework PHP tối giản, phù hợp dự án nhỏ, học tập, hoặc làm nền tảng phát triển framework cá nhân. DLight cung cấp routing, view engine (PHP/Twig/BladeOne), session & flash, database layer (builder/mapper), CLI (dli), báo lỗi/report, helper tiện ích, và một số tính năng như mail, websocket.

Mục tiêu của docs

  • Nắm luồng chạy web từ public/index.php
  • Biết nơi khai báo routes và cách map vào controller
  • Biết cách render view và tổ chức MVC
  • Biết cách dùng database theo builder hoặc mapper

Điểm nhanh

  • Web entry: public/index.php
  • Routes: app/Router/web/*.php, app/Router/api/*.php
  • Controllers: app/Controller
  • Views: resource/view
  • Core: src/ (namespace DLight\)

Hello world (route + controller + view)

Ví dụ theo đúng code mẫu sẵn có trong repo:

// app/Router/web/web.php
$router = new DLight\Application\Router();
$router->sign('GET /', [\App\Controller\HomeController::class, 'home']);
// app/Controller/HomeController.php
namespace App\Controller;
class HomeController {
  public function home() {
    return view('home', ['dlightVersion' => \DLight\Application\App::version]);
  }
}
// resource/view/home.php (file view PHP)
<h1>DLight is running</h1>