phpdevsr / minifyku
Helper versioning and minification your assets in Codeigniter 4
Fund package maintenance!
ddevsr
paypal.me/hexageek1337
Installs: 6 204
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 0
Forks: 1
Open Issues: 1
Requires
- php: ^7.4 || ^8.0
- ext-json: *
- matthiasmullie/minify: ^1.3
Requires (Dev)
- codeigniter/coding-standard: ^1.7
- codeigniter4/framework: ^4.4
- nexusphp/tachycardia: ^1.4
- php-coveralls/php-coveralls: ^2.5
- phpstan/phpstan: ^1.10
- phpunit/phpcov: ^8.2
- phpunit/phpunit: ^9.6
- rector/rector: 1.0.0
README
What is Minifyku?
Minifyku is helper versioning and minification your assets with Codeigniter 4, Can be automatically use base_url()
.
Installation
install with composer
$ composer require phpdevsr/minifyku
Configuration
$ php spark minifyku:publish
This command will copy a config file to your app namespace. Then you can adjust it to your needs. By default, file will be present in app/Config/Minifyku.php
.
public array $js = [ 'all.min.js' => [ 'bootstrap.js', 'jquery.js', 'main.js' ], ]; public array $css = [ 'all.min.css' => [ 'bootstrap.css', 'font-awesome.css', 'main.css' ], ];
This configuration will be minify and combine file bootstrap.js
,jquery.js
,main.js
to all.min.js
. Or minify and combine file bootstrap.css
,font-awesome.css
,main.css
to all.min.css
.
Since v2.0.0
, new option autoMinify
for you need automated minify when loaded using helper minifyku()
and can be replaced by .env
with minifyku.autoMinify = true
. Please dont use in production, it will take more time.
public bool $autoMinify = false;
Usage
Run command for minification your all assets:
$ php spark minifyku:minify
or you want minify JS/CSS files:
$ php spark minifyku:minify-js
$ php spark minifyku:minify-css
This will prepare everything and will set up a versioning. Make sure to load a minifier helper in your controller, by calling:
helper('minifyku');
Now to generate a proper tag with desired file to load, you have to make a simple call in your code:
minifyku('all.min.js');
or
minifyku('all.min.css');
Helper will be produce:
<script defer type="text/javascript" src="http://example.com/assets/js/all.min.js?v=bc3d0dc779f1a0b521b69ed3a2b85de8"></script>
or
<link rel="stylesheet" href="http://localhost/assets/css/all.min.css?v=ec8d57dd8de143d7ef822a90fca20957">
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contrib
We does accept and encourage contributions from the community in any shape. It doesn't matter whether you can code, write documentation, or help find bugs, all contributions are welcome.
Made with contrib.rocks.