ronanchilvers / bundler
Simple file bundler
dev-main
2025-09-23 21:03 UTC
Requires
- corneltek/getoptionkit: ^2.7
- symfony/yaml: ^7.3
Requires (Dev)
- phpunit/phpunit: ^11.5
This package is auto-updated.
Last update: 2025-09-26 15:30:04 UTC
README
A simple bundler to concatenate and version static files, optionally writing correct HTML tags.
Goals
- Simple to use
- No dependencies
- Support CSS and JS
- Support HTML tag generation
- Support versioning (cache busting)
- Support multiple bundles
- Facilitate extending to add extra features such as minification
- Implement a Config object to centralise configuration variables
- Support browser inportmaps
Usage
<?php use Ronanchilvers\Bundler\Bundler; use Ronanchilvers\Bundler\Output\Decorator\SRI; ?> <html> <head> <title>Testing 123</title> <?= Bundler::stylesheet() ->decorate(SRI::class, [ 'source' => __DIR__ . '/source/css', 'algorithms' => ['sha384'], ]) ->render([ 'resources/css/one.css', 'resources/css/two.css', ]); ?> </head> <body> <h1>Hallo!</h1> <p>lorem ipsum quod erat</p> <?= Bundler::javascript() ->decorate(SRI::class, [ 'source' => __DIR__ . '/source/js', 'algorithms' => ['sha384'], ]) ->render([ 'resources/js/one.js', 'resources/js/two.js', ]); ?> </body> </html>
Development & Testing
This project uses PHPUnit. A basic test harness is already configured.
Install dependencies
composer install
Run the test suite
composer test
Additional scripts
composer test:dox # Readable "spec" style output
composer test:coverage # Generates HTML coverage in build/coverage/html
composer test:ci # Clover + JUnit logs in build/logs/
Writing tests
- Place unit tests under tests/Unit
- Name test files with the suffix Test.php (e.g. BundlerTest.php)
- Use namespaces under Tests\Unit (e.g. namespace Tests\Unit;)
- Each test method should be public and start with test, or use #[Test] attributes.
An example test exists at tests/Unit/ExampleTest.php covering the Example class in src/Example.php. Feel free to delete these once you begin implementing real functionality.
Code coverage
Coverage reports are written to build/. Add build/ to your .gitignore if you commit coverage locally:
echo "build/" >> .gitignore
Continuous Integration
Use the test:ci script in CI workflows to produce Clover (coverage) and JUnit (test result) artifacts for reporting.