PHPackages                             bupy7/yii2-bbcode - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. bupy7/yii2-bbcode

AbandonedArchivedYii2-extension[Parsing &amp; Serialization](/categories/parsing)

bupy7/yii2-bbcode
=================

A lightweight but extensible BBCode parser for Yii2 with filter HtmlPurifier.

v1.1.2(8y ago)1012.8k↓50%41BSD-3-ClausePHPPHP &gt;=5.4.0

Since Feb 7Pushed 8y ago3 watchersCompare

[ Source](https://github.com/bupy7/yii2-bbcode)[ Packagist](https://packagist.org/packages/bupy7/yii2-bbcode)[ Docs](https://github.com/bupy7/yii2-bbcode)[ RSS](/packages/bupy7-yii2-bbcode/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (5)Used By (1)

yii2-bbcode
===========

[](#yii2-bbcode)

Behavior for parsing BB-codes at base jBBCode and HtmlPurifier for Yii2. This behavior very simple expand under your demands. Behavior of use [jBBCode](http://jbbcode.com) and [HtmlPurifier](http://htmlpurifier.org/).

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
$ php composer.phar require bupy7/yii2-bbcode "1.*"

```

or add

```
"bupy7/yii2-bbcode": "1.*"

```

to the **require** section of your **composer.json** file.

How it use
----------

[](#how-it-use)

Add you view following code:

```
echo $form->field($model, 'content')->textArea();
```

Add you model following code:

```
use bupy7\bbcode\BBCodeBehavior;

public function behaviors()
{
    return [
        ...

        [
            'class' => BBCodeBehavior::className(),
            'attribute' => 'content',
            'saveAttribute' => 'purified_content',
        ],

        ...
    ];
}
```

Support BB-code
---------------

[](#support-bb-code)

**BB-code****HTML Result**`[b]bold[/b]``bold``[i]italic[/i]``italic``[u]underline[/u]``underline``[url=http://github.com]GitHub[/url]``GitHub``[color=red]color[/color]``color``[img=My photo]http://link.to/image.png[/img]````[img]http://link.to/image.png[/img]````[p]paragraph[/p]``paragraph``[quote]blockquote[/quote]``blockquote``[h=1]header 1[/h]``header 1``[h=2]header 2[/h]``header 2``[h=3]header 3[/h]``header 3``[h=4]header 4[/h]``header 4``[h=5]header 5[/h]``header 5``[h=6]header 6[/h]``header 6``[center]align by center[/center]``align by center``[left]align by left[/left]``align by left``[right]align by right[/right]``align by right``[hr][/hr]````[list][*]first[*]second[/list]``firstsecond``[list=1][*]first[*]second[/list]``firstsecond``[table][tr][td]first[/td][td]second[/td][/tr][/table]``firstsecond`How added new BB-code
---------------------

[](#how-added-new-bb-code)

Adding new custom bbcodes to your parser is easy. For simple text-replacement bbcodes, just create a replacement string that contains {param} where the bbcode's content should go. Optionally, you may use the {option} variable for an option.

Example:

```
public function behaviors()
{
    return [
        ...

        [
            'class' => BBCodeBehavior::className(),
            'attribute' => 'content',
            'saveAttribute' => 'purified_content',
            'codeDefinitionBuilder' => [
                // as elements of array
                ['quote', '{param}'],

                // as class name where class is instance of extended class \JBBCode\CodeDefinitionBuilder
                '/namespace/to/CodeDefinitionBuilder/ExtendedClassName',

                // as extended instance of extended class \JBBCode\CodeDefinitionBuilder
                $className,

                // as callable function where $builder is instance of class \JBBCode\CodeDefinitionBuilder
                function($builder) {
                    $builder->setTagName('code');
                    $builder->setReplacementText('{param}');
                    return $builder->build();
                },
            ],
        ]
        ...
    ];
}
```

Add BB-code definitions extended of class \\JBBCode\\CodeDefinitionSet

Example:

```
public function behaviors()
{
    return [
        ...

        [
            'class' => BBCodeBehavior::className(),
            'attribute' => 'content',
            'saveAttribute' => 'purified_content',
            'codeDefinitionSet' => [
                // as class name where class is instance of extended class \JBBCode\CodeDefinitionSet
                '/namespace/to/CodeDefinitionSet/ExtendedClassName',

                // as extended instance of extended class \JBBCode\CodeDefinitionSet
                $className,
            ],
        ],

        ...
    ];
}
```

Add BB-code definitions extended of class \\JBBCode\\CodeDefinition

Example:

```
public function behaviors()
{
    return [
        ...

        [
            'class' => BBCodeBehavior::className(),
            'attribute' => 'content',
            'saveAttribute' => 'purified_content',
            'codeDefinition' => [
                // as class name where class is instance of extended class \JBBCode\CodeDefinition
                '/namespace/to/CodeDefinition/ExtendedClassName',

                // as extended instance of extended class \JBBCode\CodeDefinition
                $className,
            ],
        ],

        ...
    ];
}
```

HtmlPurifier
------------

[](#htmlpurifier)

After and before parsing BB-code can aplly HtmlPurifier with different configuration. See `bupy7\bbcode\BBCodeBehavior` for addition information.

License
-------

[](#license)

yii2-bbcode is released under the BSD 3-Clause License.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 98.7% 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 ~365 days

Total

4

Last Release

3022d ago

### Community

Maintainers

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

---

Top Contributors

[![bupy7](https://avatars.githubusercontent.com/u/5145037?v=4)](https://github.com/bupy7 "bupy7 (75 commits)")[![foritstep](https://avatars.githubusercontent.com/u/15648702?v=4)](https://github.com/foritstep "foritstep (1 commits)")

---

Tags

parseryii2extensionBehaviorbbcode

### Embed Badge

![Health badge](/badges/bupy7-yii2-bbcode/health.svg)

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

###  Alternatives

[thunderer/shortcode

Advanced shortcode (BBCode) parser and engine for PHP

3892.6M44](/packages/thunderer-shortcode)[kdn/yii2-json-editor

JSON editor widget (josdejong/jsoneditor) for Yii 2.

22570.0k3](/packages/kdn-yii2-json-editor)[taufik-nurrohman/parsedown-extra-plugin

Configurable Markdown to HTML converter with Parsedown Extra.

5932.3k](/packages/taufik-nurrohman-parsedown-extra-plugin)[pherum/laravel-bbcode

Parse your BBCode easy with this library.

2427.5k](/packages/pherum-laravel-bbcode)

PHPackages © 2026

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