My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
sfCustomMinifyPlugin  

Phase-Implementation
Updated Jan 9, 2008 by krac...@gmail.com

sfCustomMinify plugin

Integrate the minify library see http://code.google.com/p/minify/ into symfony.

Overview

Combines, minifies, and caches JavaScript and CSS files on demand to speed up page loads.

Author

Gordon Franke && Matthieu Bozec

Installation

To install sfMinifyPlugin, type:

$ symfony plugin-install http://plugins.symfony-project.com/sfMinifyPlugin

Usage

  • add this to your .htaccess file
  • # Combine and minify JavaScript and CSS with Minify.
    RewriteRule ^(.*\.)(swf|jpg|gif|png)\.v(.*)$ $1$2 [L,NC]
    RewriteRule (.*)\.(css|js)((\.v\..*){0,1})$ sfMinifyPlugin.php?files=/$1.$2 [L,NC] 
  • copy 'plugins/sfMinifyPlugin/web/sfMinifyPlugin.php' to your 'web' dir and edit the constants 'SF_APP' and 'SF_ENVIRONMENT'

Filter or Helper

you can activate minify over the filter or with the helpers

  • change the common filter in your 'filters.yml' to
  • <?php if (SF_ENVIRONMENT === 'prod'): ?>
    common:
      class: sfMinifyFilter   # Filter class
    <?php else: ?>
    common:
      class: sfMinifyDevFilter   # Filter class
    <?php endif; ?>

Configuration

you can use some minify options. Simple add in your app.yml

all:
  sf_minify_plugin:
    # this values use as default symfony settings (see 'settings.yml')
    encoding: utf-8
    use_cache: false

    # this values use as default the minify settings
    base_dir: 
    cache_dir:
    max_files:
    rewrite_css_urls:

Api

  • include the helper
  • <?php use_helper('SfMinify') ?>
  • use
  • minify_include_javascript()
    minify_include_stylesheets()
    minify_get_javascripts()
    minify_get_stylesheets()
instate of
include_javascript()
include_stylesheets()
get_javascripts()
get_stylesheets()

Custom for A-grade with Y-Slow

<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/javascript
</IfModule>

<IfModule mod_expires.c>
  ExpiresActive On
  <FilesMatch "\.(gif|png|jpg|swf)$">
    ExpiresDefault "access plus 10 years"
  </FilesMatch>

  ExpiresByType application/x-javascript "access plus 10 years"
  ExpiresByType text/css "access plus 10 years"
  ExpiresByType text/javascript "access plus 10 years"
</IfModule>

Attention

  • css hacks not works, minify remove all comments

Todos

  • symlinks e.q. sf/

Changelog

trunk

  • initial release
Powered by Google Project Hosting