Yii 1.1: yii-prettify

Syntax highlighting tool of source code snippets

This widget enable syntax highlighting of code snippets in your web application using Google Code Prettify.


Yii 1.1.6 or above...(tested with 1.1.10)


  • install and explore the demo application
  • or extract the widget file under .../protected/extensions
  • put in a view a code block like the following...

Sample : HTML code

<?php $this->beginWidget('ext.prettify.JPrettify');?>
<!DOCTYPE html>
    <meta charset="UTF-8">
    <title>Code Sample</title>
    <b>Hello World!</b>
<?php $this->endWidget();?>

Sample : PHP code from file

    'htmlOptions'=>array('style'=>'max-height: 340px; overflow-y: scroll;')

Sample : HTML5 code from any website

    'htmlOptions'=>array('style'=>'max-height: 600px; overflow-y: scroll;'))

Change log

Version 1.0

  • initial release

Version 1.1

  • code cleaning
  • bug fix
  • better support for highlighting of PHP5 keywords


Google Code Prettify

Alternate Yii extension

Be the first person to leave a comment

Please to leave your comment.

Create extension