2017 © Pedro Peláez
 

library laravel-bbcode

Parse your BBCode easy with this library.

image

pherum/laravel-bbcode

Parse your BBCode easy with this library.

  • Sunday, March 18, 2018
  • by PheRum
  • Repository
  • 2 Watchers
  • 3 Stars
  • 186 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 81 % Grown

The README.md

Laravel BBCode

Latest Version on Packagist ![Software License][ico-license] Build Status StyleCI ![Quality Score][ico-code-quality] Total Downloads, (*1)

Description

Parse your BBCode easy with laravel-bbcode, (*2)

Install

Via Composer, (*3)

``` bash composer require pherum/laravel-bbcode, (*4)


## Usage To parse some text it's as easy as this! ``` php $bbcode = new PheRum\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 PheRum\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 PheRum\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 PheRum\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 PheRum\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 5. Just open your app.php config file., (*9)

In there you just add this to your providers array ``` php PheRum\BBCode\BBCodeServiceProvider::class,, (*10)


And this to your facades array ``` php 'BBCode' => PheRum\BBCode\Facades\BBCode::class,

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

18/03 2018

dev-master

9999999-dev http://github.com/pherum/laravel-bbcode

Parse your BBCode easy with this library.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel parser bbcode

18/03 2018

1.0.4

1.0.4.0 http://github.com/pherum/laravel-bbcode

Parse your BBCode easy with this library.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel parser bbcode

28/12 2017

1.0.3

1.0.3.0 http://github.com/pherum/laravel-bbcode

Parse your BBCode easy with this library.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel parser bbcode

28/12 2017

1.0.2

1.0.2.0 http://github.com/pherum/laravel-bbcode

Parse your BBCode easy with this library.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel parser bbcode

27/12 2017

1.0.1

1.0.1.0 http://github.com/pherum/laravel-bbcode

Parse your BBCode easy with this library.

  Sources   Download

MIT

The Requires

 

laravel parser bbcode

27/12 2017

1.0.0

1.0.0.0 http://github.com/pherum/laravel-bbcode

Parse your BBCode easy with this library.

  Sources   Download

MIT

The Requires

 

laravel parser bbcode