PHPackages                             kpicaza/code-highlight-bundle - 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. kpicaza/code-highlight-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

kpicaza/code-highlight-bundle
=============================

Simple way to display highighted code in our content using highlight.js library.

0431PHP

Since Jan 5Pushed 10y ago1 watchersCompare

[ Source](https://github.com/kpicaza/CodeHighlightBundle)[ Packagist](https://packagist.org/packages/kpicaza/code-highlight-bundle)[ RSS](/packages/kpicaza-code-highlight-bundle/feed)WikiDiscussions master Synced 2w ago

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

CodeHighlightBundle
===================

[](#codehighlightbundle)

Simple way to display highighted code in our content using highlight.js library. Works nice with markdown text inputs.

[![knpbundles.com](https://camo.githubusercontent.com/d6dcd60677adad68595dd078fee63b47915d6d59e64dab00cca816a580510b56/687474703a2f2f6b6e7062756e646c65732e636f6d2f6b706963617a612f436f6465486967686c6967687442756e646c652f6261646765)](http://knpbundles.com/kpicaza/CodeHighlightBundle)

\##1. Instalation:

Add the following to your composer json:

```
// composer.json
"require": {
    ...,
    "components/highlightjs": "^9.0",
    "kpicaza/code-highlight-bundle": "0.1.x-dev",
    ...
}

```

or open console and type

```
composer require kpicaza/code-highlight-bundle=dev-master

```

Activate bundle in your kernel:

```
// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
      ...
      new Kpicaza\Bundle\CodeHighlightBundle\CodeHighlightBundle(),
      ...
}

```

Enable routing (optional, only if you wish to play demo at http://you\_site.com/highlight/hello/{name}):

```
// app/config/routing.yml
code_highlight:
    resource: "@CodeHighlightBundle/Resources/config/routing.yml"
    prefix:   /hightlight

```

\##2. Config:

Now we need to update Assetic configuration to enable js and css from highlight.js library

```
// app/config/config.yml
# Assetic Configuration
assetic:
    ...
    bundles:        [ CodeHighlightBundle ] #enables bundle mapping by assetic
    ...
    assets:
        ...
        highlight_js: # enable javascript library
            inputs:
                - %kernel.root_dir%/../vendor/components/highlightjs/highlight.pack.min.js
            output: js/highlight.js
        # Import wanted themes for highlight see https://highlightjs.org/static/demo/
        # for example I'm going to enable two themes, monokai_sublime and github
        highlight_monokai_sublime_css:
            inputs:
                - %kernel.root_dir%/../vendor/components/highlightjs/styles/monokai_sublime.css
            output: css/highlight.css
        highlight_github_css:
            inputs:
                - %kernel.root_dir%/../vendor/components/highlightjs/styles/github.css
            output: css/highlight.css

```

Now we can import files:

```
php app/console assetic:dump
php app/console assets:install

```

\##3. Usage:

\###3.1 Basic Usage:

Add stylesheet and init javascript in your template

```

    CodeHighlightBundle Demo

        {{ highlight_theme('monokai_sublime') }}

        ...

            ...

        {{ highlight_init_js() }}

```

Add "hljs" and programming language name as classes to html "pre" tag to highlight content, for example:

```

    class MyClass {
        private $foo;

        public function _construct($foo = null)
        {
            $this->foo = $foo;
        }
    }

```

\###3.2 Advanced Usage: @todo

\##4. @todo

- 4.1 Adbanced usage documentation
- 4.2 only add templating service as depency instead of service\_container
- 4.3 tests
- 4.4 Avoid text formating issues wysiwyg editors

\##5. Library docs:

###  Health Score

21

—

LowBetter than 17% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ced65d52f5d7655f87644cd04f4c23df915efe9731bb37cc12f3fd9c31bf88d7?d=identicon)[kpicaza](/maintainers/kpicaza)

---

Top Contributors

[![kpicaza](https://avatars.githubusercontent.com/u/1093654?v=4)](https://github.com/kpicaza "kpicaza (17 commits)")

### Embed Badge

![Health badge](/badges/kpicaza-code-highlight-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/kpicaza-code-highlight-bundle/health.svg)](https://phpackages.com/packages/kpicaza-code-highlight-bundle)
```

PHPackages © 2026

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