pschur/assets

维护者

详细信息

github.com/pschur/assets

源代码

问题

资助包维护!
pschur

v1.0.0 2023-05-06 00:21 UTC

This package is auto-updated.

Last update: 2024-09-06 03:13:35 UTC


README

管理和构建简单的资产

安装

composer requrie pschur/assets

使用方法

我建议您也查看我的 示例目录

首先从 composer 导入自动加载器

<?php
use Pschur\Assets\Asset;

require __DIR__.'/vendor/autoload.php';

然后配置一些重要的事情

// REQUIRED
Asset::setAssetCache(__DIR__.'/cache'); // Define a cache where the package can store some data
Asset::setAssetUrl('/assets.php'); // Define the url, where the Asset Manager can get its data.

// OPTIONAL
Asset::setAutoOptimize(true); // If you want to create automatic optimized data set this to true. I don't recommend this while developing!

为什么需要资产管理器有独立的端点?

资产管理器会自动组织所有的样式和脚本。如果您没有优化数据,资产管理器将在每次加载新内容时构建样式和脚本。当您整体优化完毕后,它将返回静态文件。