- How do I install tehwave/laravel-shortcodes?
- Install it with Composer using composer require tehwave/laravel-shortcodes. Laravel's package auto-discovery registers the service provider, so no manual provider entry is usually needed. After that you can register your own shortcode handlers and start rendering tags in views or stored content.
- Which Laravel and PHP versions does tehwave/laravel-shortcodes support?
- Version 3.0.0 requires Laravel 12 or Laravel 13. On Laravel 12 it supports PHP 8.2 through 8.5, while Laravel 13 requires PHP 8.3 or newer. If your application is still on Laravel 11 you need to stay on the 2.x branch, and Laravel 10 or below uses the 1.x branch.
- How do I register a custom shortcode in Laravel?
- Shortcode handlers are registered with the Laravel container, typically from a service provider such as AppServiceProvider or a dedicated provider of your own. You define a tag name and point it at a handler class or closure that returns the rendered output. Once registered, that tag is available anywhere the package renders content.
- How do I use shortcodes inside Blade templates?
- You embed the shortcode token in your view content and pass that content through the package's renderer. You can call the renderer on a string inside a Blade view, or prepare the output in a model accessor before handing it to the view. The goal is cleaner, reusable markup rather than replacing Blade components.
- Can a shortcode accept attributes and enclosed content?
- Yes. The package is designed around WordPress-style shortcodes, so handlers can define attributes and also receive content enclosed between opening and closing tags. That makes it practical to build reusable fragments such as callouts, buttons, or embedded media with parameters. Your handler decides how those attributes and inner content are turned into final output.
- How do I render shortcodes stored in database or CMS content?
- Run stored content through the package's renderer before it reaches the browser, either in Blade or in a model accessor. This suits CMS pages, emails, documentation, and marketing copy that need dynamic fragments without a full page builder. Normal escaping rules for your view layer still apply to the rendered result.
- What happens when a shortcode tag is not registered or is malformed?
- The 3.0.0 release notes do not document how the parser treats unregistered or malformed tags. The realistic outcomes are silent stripping, raw passthrough, or an exception, so verify the exact behaviour in your installed version with a test case. If untrusted authors can write shortcodes, add content validation or a sanitisation layer around the rendered output.
- Does tehwave/laravel-shortcodes support nested or self-closing shortcodes?
- Nesting and self-closing tag behaviour are not described in the release notes for 3.0.0. Test the scenarios you care about directly, including any recursion or payload-size limits, before designing editorial workflows around them. If nesting is important, cover it in your acceptance tests so upgrades cannot silently change the output.
- Is it safe to let users author shortcodes in their own content?
- Shortcodes are an injection surface because a stored tag invokes a registered handler at render time. If non-privileged users can author them, restrict which tags and attributes are allowed and sanitise the rendered output before it reaches the browser. Treat the render step as an untrusted-content boundary, the same way you would any other user-generated HTML.
- Is tehwave/laravel-shortcodes actively maintained and a good production choice?
- The branch structure of 3.x for Laravel 12 and 13, 2.x for Laravel 11, and 1.x for Laravel 10 and below is a healthy sign of active maintenance. It is a single-maintainer package, though, so content with embedded shortcodes becomes a migration liability if maintenance stalls. Review its test suite and release cadence against your support policy and keep a fork contingency for expensive content.