Skip to content

A PHP package for minifying your .css and .js.

License

Notifications You must be signed in to change notification settings

jorygeerts/minify

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minify

Build Status Latest Stable Version Total Downloads License

With this package you can minify your existing stylessheet and javascript files. This process can be a little tough, this package simplies this process and automates it.

Installation

Begin by installing this package through Composer.

{
    "require": {
    	"ceesvanegmond/minify": "2.0.*"
	}
}

Laravel installation

// app/config/app.php

'providers' => [
    '...',
    'CeesVanEgmond\Minify\MinifyServiceProvider',
];

Publish the config file:

php artisan config:publish ceesvanegmond/minify

When you've added the MinifyServiceProvider an extra Minify facade is available. You can use this Facade anywhere in your application

Stylesheet

// app/views/hello.blade.php

<html>
	<head>
		...
		{{ Minify::stylesheet('/css/main.css') }}
		//or by passing multiple files
		{{ Minify::stylesheet(array('/css/main.css', '/css/bootstrap.css')) }}
		//add custom attributes
		{{ Minify::stylesheet(array('/css/main.css', '/css/bootstrap.css'), array('foo' => 'bar')) }}
	</head>
	...
</html>

Javascript

// app/views/hello.blade.php

<html>
	<body>
	...
	</body>
	{{ Minify::javascript('/js/jquery.js') }}
	//or by passing multiple files
	{{ Minify::javascript(array('/js/jquery.js', '/js/jquery-ui.js')) }}
	//add custom attributes
	{{ Minify::javascript(array('/js/jquery.js', '/js/jquery-ui.js'), array('bar' => 'baz')) }}
</html>

Config

<?php

return array(

    /*
    |--------------------------------------------------------------------------
    | App environments to not minify
    |--------------------------------------------------------------------------
    |
    | These environments will not be minified
    |
    */

    'ignore_environments' => array(
	     'local',
    ),

    /*
    |--------------------------------------------------------------------------
    | CSS path and CSS build path
    |--------------------------------------------------------------------------
    |
    | Minify is an extention that can minify your css files into one build file.
    | The css_path property is the location where your CSS files are located
    | The css_builds_path property is the location where the builded files are
    | stored.  THis is relative to the css_path property.
    |
    */

    'css_build_path' => '/css/builds/',

    /*
    |--------------------------------------------------------------------------
    | JS path and JS build path
    |--------------------------------------------------------------------------
    |
    | Minify is an extention that can minify your JS files into one build file.
    | The JS_path property is the location where your JS files are located
    | The JS_builds_path property is the location where the builded files are
    | stored.  THis is relative to the css_path property.
    |
    */

    'js_build_path' => '/js/builds/',

);

Without Laravel

<?php
$config = array(
	'ignore_environments' => 'local',
	'js_build_path' => '/js/builds/',
	'css_builds_path' => '/css/builds',
)
$minify = new CeesVanEgmond\Minify\Providers\Javascript($public_path);
$minify->add($file)

if (in_array($environment, $config['ignore_environments']))
{
    return $provider->tags();
}

if ( ! $minify->make($config['css_build_path'] ) {
	$filename = $provider->tag($config['css_build_path'] . $provider->getFilename());
}

$provider->minify();

$filename = $provider->tag($config['css_build_path'] . $provider->getFilename());
        

About

A PHP package for minifying your .css and .js.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%