2017 © Pedro Peláez
 

library bbcodeparser

Parse your BBCode easy with this library.

image

weiloon1234/bbcodeparser

Parse your BBCode easy with this library.

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 124 % Grown

The README.md

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads, (*1)

The Weiloon1234\BBCodeParser package will help you with parsing BBCode., (*2)

Install

Via Composer, (*3)

``` bash $ composer require weiloon1234/bbcodeparser, (*4)


## Usage To parse some text it's as easy as this! ``` php $bbcode = new Weiloon1234\BBCode\BBCodeParser; echo $bbcode->parse('[b]Bold Text![/b]'); // <strong>Bold Text!</strong>

Would like the parser to not use all bbcodes? Just do like this. ``` php $bbcode = new Weiloon1234\BBCode\BBCodeParser;, (*5)

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

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


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. ``` php $bbcode = new Weiloon1234\BBCode\BBCodeParser; // Case insensitive echo $bbcode->parse('[b]Bold[/b] [I]Italic![/I]', true); // <strong>Bold</strong> <em>Italic!</em> // Or like this echo $bbcode->parseCaseInsensitive('[b]Bold[/b] [i]Italic[/i]'); // <strong>Bold</strong> <em>Italic!</em>

You could also make it more explicit that the parser is case sensitive by using another helper function. ``` php $bbcode = new Weiloon1234\BBCode\BBCodeParser;, (*8)

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

If you would like to completely remove all BBCode it's just one function call away. ``` php $bbcode = new Weiloon1234\BBCode\BBCodeParser; echo $bbcode->stripBBCodeTags('[b]Bold[/b] [i]Italic![/i]'); // Bold Italic!

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., (*9)

In there you just add this to your providers array ``` php 'Weiloon1234\BBCode\BBCodeParserServiceProvider', (*10)


And this to your facades array ``` php 'BBCode' => 'Weiloon1234\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. ``` php // Simple parsing echo BBCode::parse('[b]Bold Text![/b]');, (*11)

// 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!, (*12)

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


## Testing ``` bash $ phpunit

Contributing

Please see CONTRIBUTING for details., (*14)

Credits

License

The MIT License (MIT). Please see License File for more information., (*15)

The Versions

02/03 2018

dev-master

9999999-dev http://github.com/weiloon1234/bbcodeparser

Parse your BBCode easy with this library.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

laravel parser bbcode psr-4 psr-2 psr-1

02/03 2018

1.0.0

1.0.0.0 http://github.com/weiloon1234/bbcodeparser

Parse your BBCode easy with this library.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

laravel parser bbcode psr-4 psr-2 psr-1