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): stringResource::css(string $name): stringResource::js(string $name): stringResource::scss(string $name): stringResource::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');