PHPackages                             phpygments/phpygments - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. phpygments/phpygments

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

phpygments/phpygments
=====================

Syntax highlighter bridge for pygments

1.0.2(12y ago)111913[2 issues](https://github.com/capy/PHPygments/issues)MITCSSPHP &gt;=5.3

Since Apr 26Pushed 8y ago2 watchersCompare

[ Source](https://github.com/capy/PHPygments)[ Packagist](https://packagist.org/packages/phpygments/phpygments)[ Docs](https://github.com/capy/PHPygments)[ RSS](/packages/phpygments-phpygments/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)DependenciesVersions (4)Used By (0)

PHPygments - PHP syntax highlighter based on [Pygments](http://pygments.org/)
=============================================================================

[](#phpygments---php-syntax-highlighter-based-on-pygments)

Server side syntax highlighter based on Pygments highlighter software.

Installation:
-------------

[](#installation)

To use this plugin you need pygments in your server:

```
sudo apt-get install python-setuptools
easy_install Pygments

```

That's all. Now you can download the plugin via Composer or as independent library and use it.

Usage
-----

[](#usage)

```
require "../PHPygments.php";

$code = file_get_contents("test.js");
$result = PHPygments::render($code, "js");

//Load CSS for this highlighted code
foreach ($result["styles"] as $style) {
  print '';
}

//and print the code.
echo $result["code"];
```

Options
-------

[](#options)

PHPygments::render($code, $language, $style, $linenumbers)

- `$code`: the source code to highlight
- `$language`: Language type. see section "Languages and filetypes supported" in this doc.
- `$style`: Color style to use (default to "default" style). see "Color styles" un this doc.
- `$linenumbers`: `inline` or `table`, the line numbers will be added as independent table column or as part of the line.

Examples
--------

[](#examples)

```
[javascript]
//comment line
var foo = "foo";
var bar = function(){
	var baz;
}
[/javascript]

```

Outputs highlighted js with **default** style, and **no** line numbers.

```
[javascript style="monokai" linenumbers="inline"]
//comment line
var foo = "foo";
var bar = function(){
	var baz;
}
[/javascript]

```

Outputs highlighted js with **monokai** style with line numbers (as part of the line).

```
[javascript style="monokai" linenumbers="table"]
//comment line
var foo = "foo";
var bar = function(){
	var baz;
}
[/javascript]

```

Outputs highlighted js with **monokai** style with line numbers (as new column).

Color styles
------------

[](#color-styles)

These are supported color styles:

- `monokai`
    [![monokai example](Documentation/img/style__0018_Layer-20.png)](Documentation/img/style__0018_Layer-20.png)
- `manni`
    [![monokai example](Documentation/img/style__0017_Layer-19.png)](Documentation/img/style__0017_Layer-19.png)
- `rrt`
    [![monokai example](Documentation/img/style__0016_Layer-18.png)](Documentation/img/style__0016_Layer-18.png)
- `perldoc`
    [![monokai example](Documentation/img/style__0015_Layer-17.png)](Documentation/img/style__0015_Layer-17.png)
- `borland`
    [![monokai example](Documentation/img/style__0014_Layer-16.png)](Documentation/img/style__0014_Layer-16.png)
- `colorful`
    [![monokai example](Documentation/img/style__0013_Layer-15.png)](Documentation/img/style__0013_Layer-15.png)
- `default`
    [![monokai example](Documentation/img/style__0012_Layer-14.png)](Documentation/img/style__0012_Layer-14.png)
- `murphy`
    [![monokai example](Documentation/img/style__0011_Layer-13.png)](Documentation/img/style__0011_Layer-13.png)
- `vs`
    [![monokai example](Documentation/img/style__0010_Layer-12.png)](Documentation/img/style__0010_Layer-12.png)
- `trac`
    [![monokai example](Documentation/img/style__0009_Layer-11.png)](Documentation/img/style__0009_Layer-11.png)
- `tango`
    [![monokai example](Documentation/img/style__0008_Layer-10.png)](Documentation/img/style__0008_Layer-10.png)
- `fruity`
    [![monokai example](Documentation/img/style__0007_Layer-9.png)](Documentation/img/style__0007_Layer-9.png)
- `autumn`
    [![monokai example](Documentation/img/style__0006_Layer-8.png)](Documentation/img/style__0006_Layer-8.png)
- `bw`
    [![monokai example](Documentation/img/style__0005_Layer-7.png)](Documentation/img/style__0005_Layer-7.png)
- `emacs`
    [![monokai example](Documentation/img/style__0004_Layer-6.png)](Documentation/img/style__0004_Layer-6.png)
- `vim`
    [![monokai example](Documentation/img/style__0003_Layer-5.png)](Documentation/img/style__0003_Layer-5.png)
- `pastie`
    [![monokai example](Documentation/img/style__0002_Layer-4.png)](Documentation/img/style__0002_Layer-4.png)
- `friendly`
    [![monokai example](Documentation/img/style__0001_Layer-3.png)](Documentation/img/style__0001_Layer-3.png)
- `native`
    [![monokai example](Documentation/img/style__0000_Layer-1.png)](Documentation/img/style__0000_Layer-1.png)

Languages and filetypes supported
---------------------------------

[](#languages-and-filetypes-supported)

Pygments not only highlights languages. also highlights filetypes like .conf **Nginx** configuration file, **Apache** (filenames .htaccess, apache.conf, apache2.conf), etc.

NOTE: to use see "Usage" section

##### General

[](#general)

- `apacheconf`: (.htaccess, apache.conf, apache2.conf)
- `bash`, `sh`, `ksh`: (\*.sh, \*.ksh, \*.bash, \*.ebuild, \*.eclass, .bashrc, bashrc)
- `ini`, `cfg`: (\*.ini, \*.cfg)
- `makefile`: (*.mak, Makefile, makefile, Makefile.*, GNUmakefile)
- `nginx`: Nginx configuration file
- `yaml`: (\*.yaml, \*.yml)
- `perl`: Perl (\*.pl, \*.pm)
- `vb.net`: VB.net (\*.vb, \*.bas)
- `console`: Bash Session (\*.sh-session)

##### Javascript

[](#javascript)

- `javascript`: Pure Javascript
- `coffeescript`: Pure CoffeeScript
- `json`: Pure JSON

##### PHP

[](#php)

- `cssphp`: PHP embedded in CSS
- `htmlphp`: PHP embedded in HTML
- `jsphp`: PHP embedded in JS
- `php`: Pure PHP
- `xmlphp`: PHP embedded in XML

##### Ruby

[](#ruby)

- `ruby`, `duby`: Ruby (\*.rb, \*.rbw, \*.rake, \*.gemspec, \*.rbx, \*.duby)
- `csserb`, `cssruby`: Ruby embedded in CSS
- `xmlerb`, `xmlruby`: Ruby embedded in XML

##### CSS and CSS compilers

[](#css-and-css-compilers)

- `css`: CSS (\*.css)
- `sass`: Sass (\*.sass)
- `scss`: SCSS (\*.scss)

##### HTML and HTML template systems

[](#html-and-html-template-systems)

- `html`: HTML (\*.html, \*.htm, \*.xhtml, \*.xslt)
- `haml`: Haml (\*.haml)
- `jade`: Jade (\*.jade)

##### SQL

[](#sql)

- `sql`: SQL (\*.sql)
- `sqlite3`: sqlite3con (\*.sqlite3-console)
- `mysql`: MySQL

##### Python, jinja &amp; Django

[](#python-jinja--django)

- `python`: Pure Python
- `python3`: Pure Python 3
- `xmldjango`, `xmljinja`: Django/Jinja embedded in XML
- `cssdjango`, `cssjinja`: Django/Jinja embedded in CSS
- `django`, `jinja`: Pure Django/Jinja
- `htmldjango`, `htmljinja`: Django/Jinja embedded in HTML
- `jsdjango`, `jsjinja`: Django/Jinja embedded in Javascript

##### Java &amp;&amp; family

[](#java--family)

- `java`: Java (\*.java)
- `clojure`: clojure (\*.clj)
- `groovy`: Groovy (\*.groovy)
- `jsp`: Java Server Page (\*.jsp)

##### C, C++, Objetive-c, C Sharp

[](#c-c-objetive-c-c-sharp)

- `cobjdump`: c-objdump (\*.c-objdump)
- `c`: C (\*.c, \*.h, \*.idc)
- `cpp`: C++ (\*.cpp, \*.hpp, \*.c++, \*.h++, \*.cc, \*.hh, \*.cxx, \*.hxx)
- `csharp`: C# (\*.cs)
- `objectivec`: (\*.m)

##### XML

[](#xml)

- `xml`: (\*.xml, \*.xsl, \*.rss, \*.xslt, \*.xsd, \*.wsdl)
- `xslt`: (\*.xsl, \*.xslt)

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 96.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~162 days

Total

3

Last Release

4490d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1402913?v=4)[Marcelo Tosco](/maintainers/capynet)[@capynet](https://github.com/capynet)

---

Top Contributors

[![capynet](https://avatars.githubusercontent.com/u/1402913?v=4)](https://github.com/capynet "capynet (25 commits)")[![S1SYPHOS](https://avatars.githubusercontent.com/u/12161504?v=4)](https://github.com/S1SYPHOS "S1SYPHOS (1 commits)")

---

Tags

highlighterSyntax highlighter

### Embed Badge

![Health badge](/badges/phpygments-phpygments/health.svg)

```
[![Health](https://phpackages.com/badges/phpygments-phpygments/health.svg)](https://phpackages.com/packages/phpygments-phpygments)
```

###  Alternatives

[vrana/jush

JUSH - JavaScript Syntax Highlighter

282.7M13](/packages/vrana-jush)[easybook/geshi

GeSHi - Generic Syntax Highlighter. This is an unmodified port of GeSHi project code found on SourceForge.

221.1M10](/packages/easybook-geshi)[slam/phpstan-extensions

Slam extension of phpstan

712.6M81](/packages/slam-phpstan-extensions)[spatie/sidecar-shiki

Run Shiki highlighting with Sidecar

3710.2k](/packages/spatie-sidecar-shiki)[luminous/luminous

A full featured syntax highlighting library.

501.8k2](/packages/luminous-luminous)[techworker/ssml

A PHP library to generate SSML.

1110.1k1](/packages/techworker-ssml)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
