chillerlan / php-bbcode
A powerful, extensive recursive regexp BBCode parser. PHP 7.2+
Requires
- php: ^7.2
- chillerlan/php-settings-container: ^1.0
- psr/log: ^1.0
- psr/simple-cache: ^1.0
Requires (Dev)
- chillerlan/php-database: ^3.0
- ezyang/htmlpurifier: ^4.10
- phpunit/phpunit: ^7.5
This package is auto-updated.
Last update: 2024-10-27 06:28:51 UTC
README
A recursive regexp BBCode parser for PHP 7+ using preg_replace_callback(), based on an example by MrNiceGuy on developers-guide.net. Handles nested tags as well as matching brackets and doesn't stumble across invalid tags.
Requirements
- PHP 7.2+
Documentation
Installation
requires composer
composer.json
(note: replace dev-master
with a version boundary)
{ "require": { "php": ">=7.2.0", "chillerlan/php-bbcode": "dev-master" } }
Manual installation
Download the desired version of the package from master or release and extract the contents to your project folder. After that:
- run
composer install
to install the required dependencies and generate/vendor/autoload.php
. - if you use a custom autoloader, point the namespace
chillerlan\BBCode
to the foldersrc
of the package
Profit!
Usage
- @todo
For an implementation example see the GWBBCoder over here: gw1-database/GWBBCode.
Language
- @todo
Notes
The parser may cause some high CPU load, depending on the input. You should never consider to use it somewhere in your output subsystem - encode on input - you'll want a preview anyway. ;)
You may also run into several bugs. In fact, the BBCoder is essentially a tool to squeeze out any PCRE related bug in PHP known to man (and perhaps unknown). Have fun! ;) It is highly recommended to use these php.ini settings, especially to disable the PCRE JIT in PHP7 which is a troublemaker. In case you happen to run into a PCRE related bug, i ask you to open an issue over here along with the bbcode which caused the error and further information.
Disclaimer!
I don't take responsibility for molten CPUs, smashed keyboards, broken HTML etc.. Use at your own risk!