2017 © Pedro Peláez
 

library yii-minify-client-script-package

A PHP console application for minifying JavaScript and CSS files of a PHP Yii web application.

image

yanli0303/yii-minify-client-script-package

A PHP console application for minifying JavaScript and CSS files of a PHP Yii web application.

  • Friday, September 18, 2015
  • by yanli0303
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Yii-MinifyClientScriptPackage

By Yan Li, (*1)

Build Status Coverage Status License PayPayl donate button, (*2)

A PHP console application for minifying JavaScript and CSS files of a PHP Yii web application., (*3)

Usage

  1. Minify JavaScript and CSS files with Ant-MinifyJsCss, (*4)

    ant -Dsrc="path to Yii web application webroot" minify, (*5)

  2. Download yiimin.phar from downloads, (*6)

  3. Open a new command/terminal window, change current directory to the Yii web app webroot, and execute following command, (*7)

    php yiimin.phar minify -v, (*8)

Example

Take the YiiWebApp in tests as an example, suppose you have 3 client script packages defined in Yii web app config file protected/config/main.php:, (*9)

'clientScript' => array(
    'class'    => 'CClientScript',
    'packages' => array(
        'jquery'   => array(
            'baseUrl' => '//code.jquery.com/',
            'js'      => array('jquery-1.11.3.min.js')
        ),
        'layout'   => array(
            'baseUrl' => 'css/layout',
            'css'     => array('pageHeader.css', 'pageFooter.css')
        ),
        'homePage' => array(
            'baseUrl' => '',
            'depends' => array('jquery', 'layout'),
            'js'      => array('js/homePage/homePage.js'),
            'css'     => array('css/homePage/homePage.css')
        )
    )
)

Firstly you need to minify each local JavaScript and CSS files, after doing so, you'll have the following files: - css/layout/pageHeader.min.css - css/layout/pageFooter.min.css - css/homePage/homePage.min.css - js/homePage/homePage.min.js, (*10)

Then, with this tool:, (*11)

  1. Open a new terminal window, change current directory to YiiWebApp
  2. Run php yiimin.phar minify -v

After that, your config file will be changed to:, (*12)

'clientScript' => array(
    'class' => 'CClientScript',
    'packages' => array(
        'jquery' => array(
            'baseUrl' => '//code.jquery.com',
            'js' => array('jquery-1.11.3.min.js')
        ),
        'layout' => array(
            'baseUrl' => '',
            'css' => array('assets/layout_d7863...48618.min.css')
        ),
        'homePage' => array(
            'baseUrl' => '',
            'depends' => array('jquery'),
            'css' => array('assets/homePage_d8e21...fa8f7.min.css'),
            'js' => array('assets/homePage_8cc59...57c458.min.js')
        )
    )
)

And the assets/homePage_d8e21...fa8f7.min.css comprises the contents of following files: - css/layout/pageHeader.min.css - css/layout/pageFooter.min.css - css/homePage/homePage.min.css, (*13)

Limitations

  • Better to only register one client script package on a page/view. If you registered several packages on a page, make sure the packages don't depend on a same package, otherwise the resources of the shared package will be loaded on the page multiple times;
  • Don't use registerCssFile or registerScriptFile anymore; use registerPackage instead.

Run tests

  1. Install composer and run composer install
  2. Install PHPUnit and run phpunit

Build PHAR from source

  1. Download box.phar
  2. Open a new terminal/command prompt window, change current directory to this console application
  3. Run php /path/to/box.phar build, new yiimin.phar will be created in downloads

The Versions

18/09 2015

dev-master

9999999-dev

A PHP console application for minifying JavaScript and CSS files of a PHP Yii web application.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yan Li

10/06 2015

v0.4

0.4.0.0

A PHP console application for minifying JavaScript and CSS files of a PHP Yii web application.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yan Li

05/06 2015

0.3

0.3.0.0

A PHP console application for minifying JavaScript and CSS files of a PHP Yii web application.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yan Li

03/06 2015

0.2

0.2.0.0

A PHP console application for minifying JavaScript and CSS files of a PHP Yii web application.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yan Li

01/06 2015

0.1

0.1.0.0

A PHP console application for minifying JavaScript and CSS files of a PHP Yii web application.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Yan Li