sfGeshiPlugin - 1.0.0

sfGeshiPlugin provides easy use of the Generic Syntax Highlighter (GeSHi)

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
Show source

sfGeshiPlugin

Provides easy use of Generic Syntac Highlighter (GeSHi) in symfony projects. Current release of the plugin is based on version 1.0.8.5 of GeSHI.

Installation

$ ./symfony plugin:install sfGeshiPlugin

The plugin is provided with an example module to test if everything works fine. Go to your application config directory and add sfGeshiExample module to enabled modules section in settings.yml file. Next step is to edit config/routing.yml file of the plugin - you shall uncomment all lines. Then clear the cache:

$ ./symfony cc

and everything is ready to run:

http://local.site/geshi

in your browser. You shall see a demonstration of highlighting PHP code of the actions.class.php file.

Usage

It's obvious - store all the code you want to highlight in one variable and pass it as the first parameter to sfGeshi class constructor. The second parameter is the language name. See the example below:

$code_orig = "<?php echo \"hello GeSHi\"; ?>";
$geshi = new sfGeshi($code_orig, 'php');
$code_high = $geshi->parse_code();

sfGeshiExample

The plugin provides a GeSHi syntax highlighting example. The code is generated inside the action:

$geshi = new sfGeshi(implode("", file(__FILE__)), 'php');
$this->code = $geshi->parse_code();

and displayed in the template:

<?php echo $code ?>

As you can see, there's nothing difficult.

Documentation

See the GeSHi documentation.