Luminous - a Syntax Highlighter for PHP - v0.6.5

Luminous is an accurate and style-able syntax highlighter for PHP which supports a bunch of common languages and output to HTML and LaTeX.

Links:

Installation

Extract your tarball, zip, whatever, into some directory where it's going to be used (i.e. probably your web-server). We'll assume it's called `luminous/'

Quick Usage

First, if you're going to use caching, which you probably are, create a directory called luminous/cache and give it writable permissions (chmod 777 on most servers -- yours may accept a less permissive value). Then include luminous/luminous.php and away you go!

 1 
 2 
 3 
 4 
<?php
require_once 'luminous/luminous.php';
echo luminous::head_html(); // outputs CSS includes, intended to go in <head>
echo luminous::highlight('c', 'printf("hello world\n");');

Useful examples can be found in luminous/examples/. If you have problems, check that luminous/examples/example.php works.

Command Line Usage

If you're crazy and want to use Luminous/PHP on the command line, guess what, you can!

 1 
 2 
$ cd luminous/
$ php luminous.php --help

Polite Warning

Luminous is pretty slow. It's perfectly usable for highlighting several-KB snippets on a blog or similar, and it also caches so highlighting is a one-time overhead. Throughput is roughly 50-200 KB/s depending on the language. In most use cases, this is easily fast enough, especially once you consider that highlights are cached and therefore there is no real penalty most of the time. You may need to run your own tests to decide whether or not it is suitable for you.

Caching

The cache can be stored either directly on the file system or in a MySQL table (support for other DBMSs will come later, patches welcome). In either case, check out the cache documentation.

Licensing

Luminous is distributed under the GPL3 but includes a bunch of stuff which is separate.