mrclay/jsmin-php
PHP port of Douglas Crockford’s JSMin for minifying JavaScript. Removes comments and unnecessary whitespace to shrink files while preserving behavior. Lightweight and simple to integrate into build scripts or server-side workflows.
ord(null) deprecation ensures compatibility with modern PHP versions, aligning with Laravel 9/10’s requirements.composer.json to reflect:
"require": {
"mrclay/jsmin-php": "^2.4.1",
"php": "^8.1"
}
package.json scripts to target PHP 8.1+:
"scripts": {
"prod": "mix --prod && php artisan jsmin:minify public/js"
}
ord(null) calls).2.4.1 to avoid auto-updates until PHP 8.2+ support is confirmed.composer.json:
"config": {
"platform": {
"php": "8.1"
}
}
php:
- 8.1
- 8.2 # Test manually if critical
PHPUnit using PHPUnit\Runner\Version to validate compatibility.README.md to note PHP 8.1+ requirement and lack of 8.2+ support.[JSMin] PHP 8.1.2 detected. Minification failed for script.js: ord() expects parameter 1 to be int, null given
| Failure Scenario | Impact | Mitigation |
|---|---|---|
| PHP 8.2+ Deprecation Warnings | Runtime errors | Downgrade PHP or fork the package. |
| JS Syntax Errors (8.1+) | Broken frontend | Rollback to unminified; add validation layer. |
| High CPU Load (Runtime) | Server slowdown | Disable in production; use pre-minification. |
| Dependency Conflicts (8.1+) | Composer install fails | Isolate in a vendor directory or use platform-check. |
Blade::directive('ignoreMinify', function () {
return '<?php echo $__env->ignoreMinify = true; ?>';
});
- name: Check PHP version
run: |
if [ "$(php -r 'echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;')" != "81" ]; then
echo "PHP 8.1 required for jsmin-php"
exit 1
fi
How can I help you explore Laravel packages today?