scafera/asset
Composer 安装命令:
composer require scafera/asset
包简介
Asset management for the Scafera framework
关键字:
README 文档
README
Asset management for the Scafera framework. Configures Symfony's AssetMapper internally — your code references assets via asset() in Twig templates, never through PHP imports.
Provides: Asset management for Scafera — configures Symfony's AssetMapper internally; projects reference assets via Twig's
asset()function, never PHP imports. Companion bundles (e.g. TailwindBundle) auto-register when installed.Depends on: A Scafera host project with
scafera/frontendinstalled (for Twig'sasset()function) and anassets/directory at the project root.Extension points: None of its own — AssetMapper is configured internally. Extra asset paths via
framework.asset_mapper.pathsinconfig/config.yaml. Ecosystem integrations (e.g. TailwindBundle) auto-register via the kernel'sextra.scafera-bundlesmechanism.Not responsible for: Template rendering (owned by
scafera/frontend) · JavaScript bundling (AssetMapper uses native ES modules) · Node.js tooling (TailwindBundle manages its own standalone binary) · folder conventions (owned by architecture packages).
This is a capability package (adoption gate). It adds optional asset support to a Scafera project. It does not define folder structure or architectural rules — those belong to architecture packages.
Installation
composer require scafera/asset
The bundle is auto-discovered via Scafera's symfony-bundle type detection. No manual registration needed.
Requirements
- PHP 8.4+
scafera/kernel^1.0scafera/frontend(for template rendering withasset())
Usage
Referencing assets in templates
Place CSS, JS, and other static files in assets/ at your project root. Reference them in Twig templates using the asset() function:
<link rel="stylesheet" href="{{ asset('styles/app.css') }}"> <script src="{{ asset('js/app.js') }}"></script> <img src="{{ asset('images/logo.png') }}">
Using with Tailwind CSS
Install the TailwindBundle — it is auto-registered as a companion bundle:
composer require symfonycasts/tailwind-bundle
Initialize and build:
vendor/bin/scafera symfony tailwind:init vendor/bin/scafera symfony tailwind:build
For development with auto-rebuild on file changes:
vendor/bin/scafera symfony tailwind:build --watch
Reference the compiled CSS in your template:
<link rel="stylesheet" href="{{ asset('styles/app.css') }}">
Production deployment
Compile assets with versioned filenames for cache busting:
vendor/bin/scafera symfony asset-map:compile
This writes versioned files to public/assets/ for direct serving by the web server.
Companion Bundles
This package declares companion bundles via extra.scafera-bundles in its composer.json. When you install a companion package, Scafera registers its bundle automatically — no manual configuration needed.
| Package | Bundle | Purpose |
|---|---|---|
symfonycasts/tailwind-bundle |
SymfonycastsTailwindBundle |
Tailwind CSS compilation via standalone binary |
Companions are only registered when installed. If you don't composer require the package, the declaration is ignored.
Boundary Enforcement
This package includes an AssetMapperLeakageValidator that scans your src/ directory for direct Symfony\Component\AssetMapper\* imports. Violations are reported by scafera validate:
Package checks:
✗ No AssetMapper imports in userland FAILED
- src/Service/AssetHelper.php: imports AssetMapper types directly — use asset() in Twig templates instead
Use asset() in templates — don't import AssetMapper types in PHP.
Configuration
The bundle configures AssetMapper automatically:
- Asset paths:
assets/at your project root - Public prefix:
/assets/
To override defaults, add a framework: section to config/config.yaml:
framework: asset_mapper: paths: - 'assets/' - 'vendor/some-package/assets/'
License
MIT
scafera/asset 适用场景与选型建议
scafera/asset 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「asset」 「asset-mapper」 「scafera」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 scafera/asset 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 scafera/asset 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 scafera/asset 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Assets Minifier (CSS, JS) for Symfony & Minify integration in Asset Mapper
Asset for Bulma Free for YiiFramework v.3.0.
Google Fonts integration for Symfony with development CDN and production font locking
Symfony Utils Bundle
Asset Bundle to include Masonry on your Yii 2 project
Delightful Sass Support for Symfony + AssetMapper
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 36
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-13