承接 jbsnewmedia/asset-composer-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jbsnewmedia/asset-composer-bundle

最新稳定版本:1.1.7

Composer 安装命令:

composer require jbsnewmedia/asset-composer-bundle

包简介

A Symfony bundle to help you manage your assets

README 文档

README

Packagist Version Packagist Downloads PHP Version Require Symfony Version License Tests PHP CS Fixer PHPStan Rector codecov

AssetComposerBundle is a Symfony bundle that helps you manage and serve assets directly from the vendor directory. It ensures all files are kept up-to-date by leveraging file modification timestamps for cache busting.

🚀 Features

  • Manage CSS/JS assets via Composer packages
  • Automatic versioning using file timestamps
  • Simple integration with Twig templates
  • Supports production/dev-only assets via assetcomposer.json
  • Symfony 6 & 7 compatible

⚙️ Requirements

  • PHP 8.1 or higher
  • Symfony Framework 6.4 or 7.0

📦 Installation

Use Composer to install the bundle:

composer require jbsnewmedia/asset-composer-bundle

📋 Usage

1. Install Asset Packages via Composer

composer require twbs/bootstrap
composer require components/font-awesome
composer require avalynx/avalynx-alert

2. Register Assets in Twig Templates

Assets from Composer Packages

{% do addAssetComposer('twbs/bootstrap/dist/css/bootstrap.css') %}
{% do addAssetComposer('components/font-awesome/css/all.css') %}
{% do addAssetComposer('avalynx/avalynx-alert/dist/css/avalynx-alert.css') %}
{% do addAssetComposer('avalynx/avalynx-alert/dist/js/avalynx-alert.js') %}

Local Assets

You can also use local assets stored in your project's assets/ directory. Use the namespace app and the package assets:

{% do addAssetComposer('app/assets/css/custom.css') %}
{% do addAssetComposer('app/assets/js/custom.js') %}

The files must be located locally at %kernel.project_dir%/assets/css/custom.css and %kernel.project_dir%/assets/js/custom.js respectively.

Example file structure:

your-project/
├── assets/
│   ├── css/
│   │   └── custom.css
│   └── js/
│       └── custom.js
├── composer.json
└── ...

3. Render in Layout

<!DOCTYPE html>
<html>
<head>
    {% block stylesheets %}
        {{ renderAssetComposerStylesheets() }}
    {% endblock %}
</head>
<body>
    {% block body %}{% endblock %}
    
    {% block javascripts %}
        {{ renderAssetComposerJavascripts() }}
    {% endblock %}
    
    {{ renderAssetComposerJavascripts('bottom') }}
</body>
</html>

📁 File Structure

config/
├── routes.yaml
├── services.yaml
src/
├── Controller/
│   └── AssetComposerController.php
├── DependencyInjection/
│   ├── AssetComposerExtension.php
│   └── Configuration.php
├── Service/
│   └── AssetComposer.php
├── Twig/
│   └── AssetComposerExtension.php
├── AssetComposerBundle.php

🧰 Configuration (Optional)

You can create an assetcomposer.json file in your asset packages to define which files should be exposed:

{
  "name": "library-name",
  "files": [
    "dist/css/styles.css",
    "dist/js/scripts.js"
  ],
  "files-dev": [
    "src/css/dev-styles.css",
    "src/js/dev-scripts.js"
  ]
}

🔧 Development Tools

To maintain code quality, this project uses:

  • PHP-CS-Fixer (ECS): composer bin-ecs
  • PHPStan: composer bin-phpstan
  • Rector: composer bin-rector

Install and update tools using:

composer bin-ecs-install
composer bin-phpstan-install
composer bin-rector-install
composer bin-phpunit-install

🧪 Testing & QA

All code adheres to modern PHP standards. Use the provided scripts to analyze and refactor the codebase:

composer bin-phpstan       # Static analysis
composer bin-ecs           # Coding standards (check)
composer bin-ecs-fix       # Coding standards (fix)
composer bin-rector        # Code transformation (dry-run)
composer bin-rector-process # Code transformation (apply)
composer test              # Run tests
composer test-coverage     # Run tests with coverage

📜 License

This bundle is licensed under the MIT license. See the LICENSE file for more details.

Developed by Jürgen Schwind and other contributors.

🤝 Contributing

Contributions are welcome! If you'd like to contribute, please contact us or fork the repository and submit a pull request with your changes or improvements.

📫 Contact

If you have any questions, feature requests, or issues, please open an issue on our GitHub repository or submit a pull request.

Always up-to-date. Simple. Composer-native asset management.

统计信息

  • 总下载量: 200
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固