DLight\Application\Resource

Mô tả: loader đọc nội dung file tĩnh trong thư mục resource/ (mặc định ROOT_DIR/resource). Có check path traversal bằng realpath và prefix match.

Namespace / đăng ký

  • Namespace: DLight\Application
  • File: src/Application/Resource.php

Public API

  • __construct(?string $basePath = null)
  • get(string $path): string
  • Resource::css(string $name): string
  • Resource::js(string $name): string
  • Resource::scss(string $name): string
  • Resource::ts(string $name): string

Demo

use DLight\Application\Resource;

header('Content-Type: text/css; charset=utf-8');
echo Resource::css('app');
use DLight\Application\Resource;

$r = new Resource(ROOT_DIR . 'resource');
$js = $r->get('js/app.js');