thunderer/shortcode
Framework-agnostic PHP library for parsing and processing shortcodes/BBCodes. Extract shortcodes from text, handle replacements, and apply them via processors and events. Includes serializers for Text/XML/JSON/YAML. Supports PHP 5.3–8.x.
ShortcodeFacade for DI integration.@shortcode) or helper functions.content columns) and processed on-the-fly during retrieval or rendering.RegularParser is slower than regex-based alternatives. Benchmark nested shortcodes in high-traffic Laravel routes (e.g., admin dashboards).[tag]) may clash with existing HTML or Laravel-specific tags (e.g., [{{ }}] in Blade). Custom syntax (e.g., {{{shortcode}}}) may be needed.null) could lead to stack overflows with deeply nested shortcodes. Configure withRecursionDepth() based on use cases.Auth, Cache). Use dependency injection via constructor injection or Laravel’s app() helper sparingly.@include or @component)? If so, assess overlap and redundancy.RegexParser suffice for 90% of cases to reduce overhead?htmlspecialchars in handlers).[user id="123"]) that need validation?deprecated() helper or middleware.ShortcodeFacade as a singleton in AppServiceProvider::boot().Shortcode::process($content)).@shortcode) to process content in views.Post::getContentAttribute()).PostResource::toArray()) or HTTP middleware.Shortcode::serialize($shortcode, 'json')).[alert type="success"]).deprecated() helper to warn about obsolete shortcodes.Shortcode::removeHandler('old-tag')).CommonMark + Shortcode for hybrid syntax (e.g., [note]Markdown here.[/note]).Shortcode::addEventHandler(Events::FILTER_SHORTCODES, ...))./api/shortcodes/process).composer require thunderer/shortcode.publishes in AppServiceProvider.[button], [alert]).{{{tag}}}).Mockery).app/Services/ShortcodeService.php) for easier updates.php artisan config:cache) to optimize handler lookups.README.md or a dedicated wiki.php artisan shortcode:list) to dump registered shortcodes.thunderer/shortcode for breaking changes (e.g., PHP 8.2+ features).Events::FILTER_SHORTCODES for analytics.@shortcodeDebug) to inspect parsed shortcodes.ShortcodeException).Cache::remember()) for repeated content.RegexParser for simple cases and RegularParser only when nesting is required.WHERE content LIKE '%[tag]%').[tag) may break rendering. Use try-catch in handlers or a global event listener.RegularParser for strict parsing.[a][b][a][/b][/a]). Set withRecursionDepth(5) as a default.DivisionByZeroError) may crash the request.try-catch or use Laravel’s app()->bound('shortcode.handler.fallback').withMaxIterations(3).README.md (or fork itHow can I help you explore Laravel packages today?