doudaotui4297 2011-08-14 02:53
浏览 47
已采纳

将google minify与zend框架集成

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
      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?

  • 写回答

1条回答 默认 最新

  • doumaoao0182 2011-08-14 16:03
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗