s9e/text-formatter
PHP text formatting library with plugin support for BBCode, Markdown, HTML, and more. Includes predefined bundles, extensive documentation, and a JavaScript port for client-side preview and demos. Install via Composer and integrate customizable parsing/rendering.
composer require s9e/text-formatter integrates cleanly with Laravel’s dependency management.Configurator instances).Illuminate\Validation)?ProblemDetails or custom exceptions)./api/docs).posts.body) and parsed HTML separately for performance.Phase 1: Core Integration
Markdown + Autolink).// app/Providers/TextFormatterServiceProvider.php
public function register()
{
$this->app->singleton(s9e\TextFormatter\Configurator::class, function () {
$configurator = new s9e\TextFormatter\Configurator;
$configurator->Markdown;
$configurator->Autolink;
return $configurator;
});
}
use s9e\TextFormatter\Configurator;
public function __construct(private Configurator $formatter) {}
Phase 2: Feature-Specific Adoption
img tags from external domains)./api/docs routes.Phase 3: Advanced Customization
mention BBCode that links to Laravel user profiles.Configurator.posts.body).| Step | Priority | Dependencies | Output |
|---|---|---|---|
| Install & Configure | High | Composer, Laravel service container | Configurator singleton |
| Basic Parsing | High | Service provider | Markdown/BBCode → HTML pipeline |
| Security Rules | Medium | Laravel validation middleware | URL whitelists/blacklists |
| Caching | Low | Laravel cache system | Parsed HTML cache |
| Client-Side Preview | Optional | Laravel Mix/Vite, JS port | Real-time formatting UI |
s9e/text-formatter for breaking changes (SemVer compliant). Laravel’s composer update handles updates.YouTube plugin in staging).Configurator setup in a single provider to avoid scattered configs.$parser->setLogger(new s9e\TextFormatter\Logger\StreamLogger(fopen('storage/logs/parser.log', 'a')));
cache()->remember()).SELECT * on large text fields—parse only necessary chunks.| Scenario | Impact | Mitigation |
|---|---|---|
| Invalid BBCode/Markdown | Broken rendering | Fallback to raw text + error log |
| Plugin Conflict | Rendering failures | Isolate plugins in separate configs |
| URL Filter Overhead | Slow parsing | Pre-validate URLs before parsing |
| Database Corruption (raw markup) | Unparseable content | Backup strategy + validation hooks |
| JavaScript Preview Fails | Poor UX | Server-side fallback rendering |
Configurator API and custom filters.s9e\TextFormatter\Parser::startTimer()).Key Takeaway: Leverage Laravel’s ecosystem (services, caching, queues) to mitigate operational overhead while unlocking flexible, secure markup processing. Prioritize security (URL filters) and performance (caching) early.
How can I help you explore Laravel packages today?