golonka/bbcodeparser
Composer 安装命令:
composer require golonka/bbcodeparser
包简介
Parse your BBCode easy with this library.
README 文档
README
The Golonka\BBCodeParser package will help you with parsing BBCode.
Install
Via Composer
$ composer require golonka/bbcodeparser
Usage
To parse some text it's as easy as this!
$bbcode = new Golonka\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.
$bbcode = new Golonka\BBCode\BBCodeParser; echo $bbcode->only('bold', 'italic') ->parse('[b][u]Bold[/u] [i]Italic[/i]![/b]'); // <strong>[u]Bold[/u] <em>Italic</em>!</strong> echo $bbcode->except('bold') ->parse('[b]Bold[/b] [i]Italic[/i]'); // [b]Bold[/b] <em>Italic</em>
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 Golonka\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.
$bbcode = new Golonka\BBCode\BBCodeParser; 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.
$bbcode = new Golonka\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.
In there you just add this to your providers array
'Golonka\BBCode\BBCodeParserServiceProvider'
And this to your facades array
'BBCode' => 'Golonka\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]'); // <strong>[u]Bold[/u] <em>Italic</em>!</strong> // Or the except method echo BBCode::except('bold') ->parse('[b]Bold[/b] [i]Italic[/i]'); // [b]Bold[/b] <em>Italic</em>
Testing
$ phpunit
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
golonka/bbcodeparser 适用场景与选型建议
golonka/bbcodeparser 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 47.49k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2013 年 11 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「parser」 「laravel」 「bbcode」 「PSR-2」 「PSR-1」 「PSR-4」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 golonka/bbcodeparser 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 golonka/bbcodeparser 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 golonka/bbcodeparser 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Symfony FMBbCodeBundle
Easy to use SDK with grabber for multiple platforms at once like YouTube, Dailymotion, Facebook and more.
Parse your BBCode easy with this library.
BBCode parser
An MT940 bank statement parser for PHP
Adds more BBCode
统计信息
- 总下载量: 47.49k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 24
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-11-07