Skip to content

Instantly share code, notes, and snippets.

@hiscaler
Created February 11, 2012 01:00
Show Gist options
  • Save hiscaler/1794759 to your computer and use it in GitHub Desktop.
Save hiscaler/1794759 to your computer and use it in GitHub Desktop.
Yii enable gzip
<?php
class GzipBehavior extends CBehavior
{
public function events ()
{
return array ( 'onBeginRequest' => 'beginRequest','onEndRequest' => 'endRequest' );
}
public function beginRequest ()
{
return ob_start ( "ob_gzhandler" );
}
public function endRequest ()
{
return ob_end_flush ();
}
}
//on index.php
$app->attachBehavior('GzipBehavior','application.behavior.GzipBehavior');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment