PHPackages                             sonnn/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. sonnn/bbcode

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

sonnn/bbcode
============

parser bbcode

v4.0(8y ago)049PHPPHP &gt;=5.4.0

Since Mar 25Pushed 8y ago1 watchersCompare

[ Source](https://github.com/sonnam0904/bb-code)[ Packagist](https://packagist.org/packages/sonnn/bbcode)[ RSS](/packages/sonnn-bbcode/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (6)Dependencies (1)Versions (7)Used By (0)

[![Latest Version](https://camo.githubusercontent.com/9556fc9fba5b57c9e7bf4dac6e87a0782dcd96b092a55608e470188ba3223b9d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f736f6e6e6e2f6262636f64652e7376673f7374796c653d666c61742d737175617265)](https://github.com/sonnn/bbcode/v1.0)[![Total Downloads](https://camo.githubusercontent.com/f76784cbf60acbd478e0381a575a475c71953e5d9fca47d0d6ceece9999c9207/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736f6e6e6e2f6262636f64652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sonnn/bbcode)

The `Sonnn\BBCode` package will help you with parsing BBCode.

Install
-------

[](#install)

Via Composer

```
$ composer require sonnn/bbcode
```

Usage
-----

[](#usage)

To parse some text it's as easy as this!

```
$bbcode = new Sonnn\BBCode\BBCodeParser;

echo $bbcode->parse('[b]Bold Text![/b]');
// Bold Text!
```

Would like the parser to not use all bbcodes? Just do like this.

```
$bbcode = new Sonnn\BBCode\BBCodeParser;

echo $bbcode->only('bold', 'italic')
            ->parse('[b][u]Bold[/u] [i]Italic[/i]![/b]');
            // [u]Bold[/u] Italic!

echo $bbcode->except('bold')
            ->parse('[b]Bold[/b] [i]Italic[/i]');
            // [b]Bold[/b] Italic
```

By default the parser is case sensitive. But if you would like the parser to accept tags like `[B]Bold Text[/B]` it's really easy.

```
$bbcode = new Sonnn\BBCode\BBCodeParser;

// Case insensitive
echo $bbcode->parse('[b]Bold[/b] [I]Italic![/I]', true);
     // Bold Italic!

// Or like this

echo $bbcode->parseCaseInsensitive('[b]Bold[/b] [i]Italic[/i]');
     // Bold Italic!
```

You could also make it more explicit that the parser is case sensitive by using another helper function.

```
    $bbcode = new Sonnn\BBCode\BBCodeParser;

    echo $bbcode->parseCaseSensitive('[b]Bold[/b] [I]Italic![/I]');
         // Bold [I]Italic![/I]
```

If you would like to completely remove all BBCode it's just one function call away.

```
    $bbcode = new Sonnn\BBCode\BBCodeParser;

    echo $bbcode->stripBBCodeTags('[b]Bold[/b] [i]Italic![/i]');
         // Bold Italic!
```

Laravel integration
-------------------

[](#laravel-integration)

The integration into Laravel is really easy, and the method is the same for both Laravel 4 and Laravel 5. Just open your `app.php` config file.

In there you just add this to your providers array

```
'Sonnn\BBCode\BBCodeParserServiceProvider'
```

And this to your facades array

```
'BBCode' => 'Sonnn\BBCode\Facades\BBCodeParser'
```

The syntax is the same as if you would use it in vanilla PHP but with the `BBCode::` before the methods. Here are some examples.

```
// Simple parsing
echo BBCode::parse('[b]Bold Text![/b]');

// Limiting the parsers with the only method
echo BBCode::only('bold', 'italic')
        ->parse('[b][u]Bold[/u] [i]Italic[/i]![/b]');
        // [u]Bold[/u] Italic!

// Or the except method
echo BBCode::except('bold')
        ->parse('[b]Bold[/b] [i]Italic[/i]');
        // [b]Bold[/b] Italic
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity62

Established project with proven stability

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 ~44 days

Recently: every ~55 days

Total

6

Last Release

3165d ago

Major Versions

v1.6 → v2.02017-07-10

v2.1 → v3.02017-10-10

v3.0 → v4.02017-10-31

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5780387?v=4)[Son Nguyen](/maintainers/sonnn)[@sonnn](https://github.com/sonnn)

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19139.2M44](/packages/mck89-peast)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9843.5k](/packages/sauladam-shipment-tracker)[moonshine/layouts-field

Field for repeating groups of fields for MoonShine

107.9k](/packages/moonshine-layouts-field)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

112.9k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

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