开发者

integrating google minify with zend framework

so I tried to integrate minify and zend framework

http://code.google.com/p/minify/

what I basically did was copy the contents of minify's index.php file to a zend action:

and changed the third line from

define('MINIFY_MIN_DIR', dirname(__FILE__));

to

define('MINIFY_MIN_DIR', 'Z:\wamp2\www\min');

which is where the minify folder is located

here's the full action:

  public function test2Action()
    {
      define('MINIFY_MIN_DIR', 'Z:\wamp2\www\min');
       // load config
      require MINIFY_MIN_DIR . '/config.php';

      // setup include path
  开发者_Go百科    set_include_path($min_libPath . PATH_SEPARATOR . get_include_path());

      require 'Minify.php';

      Minify::$uploaderHoursBehind = $min_uploaderHoursBehind;
      Minify::setCache(
          isset($min_cachePath) ? $min_cachePath : ''
          ,$min_cacheFileLocking
      );

      if ($min_documentRoot) {
          $_SERVER['DOCUMENT_ROOT'] = $min_documentRoot;
      } elseif (0 === stripos(PHP_OS, 'win')) {
          Minify::setDocRoot(); // IIS may need help
      }

      $min_serveOptions['minifierOptions']['text/css']['symlinks'] = $min_symlinks;

      if ($min_allowDebugFlag && isset($_GET['debug'])) {
          $min_serveOptions['debug'] = true;
      }

      if ($min_errorLogger) {
          require_once 'Minify/Logger.php';
          if (true === $min_errorLogger) {
              require_once 'FirePHP.php';
              Minify_Logger::setLogger(FirePHP::getInstance(true));
          } else {
              Minify_Logger::setLogger($min_errorLogger);
          }
      }

      // check for URI versioning
      if (preg_match('/&\\d/', $_SERVER['QUERY_STRING'])) {
          $min_serveOptions['maxAge'] = 31536000;
      }
      if (isset($_GET['g'])) {
          // well need groups config
          $min_serveOptions['minApp']['groups'] = (require MINIFY_MIN_DIR . '/groupsConfig.php');
      }
      if (isset($_GET['f']) || isset($_GET['g'])) {
          // serve!
         Minify::serve('MinApp', $min_serveOptions);
         //echo Minify::combine(array('//css/DisplayHelpers/DisplayObject.css'),$min_serveOptions);

      } else{
         echo 'fail';
      }

        // action body
    }

notice these lines...I added the combine line which is commented out

 Minify::serve('MinApp', $min_serveOptions);
 //echo Minify::combine(array('//css/DisplayHelpers/DisplayObject.css'),$min_serveOptions);

the Minify::serve('MinApp', $min_serveOptions); line is in the original index.php....if I keep it there, it will not return the correct minifed files properly and instead return some crazy gibberish when I go to http://localhost/tester/test2?f=/css/DisplayHelpers/DisplayObject.css...

on the other hand, when I go to http://localhost/min?f=/css/DisplayHelpers/DisplayObject.css which uses minify's index.php it would work properly

on the other hand if I uncomment the combine line and comment the serve line it would also work properly but it won't do caching, etc

any ideas on how to resolve in using the normal serve method within the zend action so that I can use the cache?


Why an action plus there's already a Zend helper in that project.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜