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 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号