- How do I install Parsedown for Laravel with Composer?
- Run composer require parsedown/laravel on a project running PHP 7.2.3 or newer. Laravel package auto-discovery registers the service provider and facade, so modern Laravel versions need no manual entries in config/app.php. The underlying erusev/parsedown dependency is pulled in automatically. Publishing the config file is optional but recommended if you want to control safe mode and extensions.
- Which Laravel versions does parsedown/laravel support?
- The only hard gate stated in the evaluation is a PHP floor of 7.2.3, which in practice maps to Laravel 6.x and later. The exact framework constraint should be read from the illuminate/support requirement in the package composer.json before you commit, because the release notes do not enumerate supported Laravel versions. Environments below PHP 7.2.3 fail at composer install time rather than at runtime, which is the safer failure mode but still a deployment gate.
- How do I render Markdown in a Blade template with this package?
- Use the @parsedown Blade directive with the Markdown expression, for example @parsedown($post->body). The package also exposes a global parsedown() helper and a facade you can call from controllers or views. Since the directive is compiled into cached Blade views, run php artisan view:clear after upgrading the package.
- Is Parsedown Laravel safe for user-generated content, or is it an XSS risk?
- Parsedown's default configuration permits raw HTML, so the package is not safe for untrusted input unless you explicitly harden it. From version 1.2.0 the behaviour is centralised in a publishable config file, so check whether safe mode and markup escaping are enabled by default before rendering user content. Every view using the directive inherits that single configuration, so the security decision applies project-wide and should be reviewed deliberately.
- How do I publish and configure the parsedown config file?
- Run php artisan vendor:publish and choose the parsedown config tag to copy the stub into config/parsedown.php. The file configures the container-managed singleton, so its values apply to every helper, facade, and directive call. Because the release notes do not enumerate the available keys or their defaults, open the published stub and read it directly before relying on any option.
- What does the second argument to the parsedown() helper do?
- Release notes for 1.2.0 describe a second argument that inline-parses the first argument, but they do not say whether it mutates the shared singleton's parsing mode or is applied only to that call. If it mutates the instance, one call in one view can change rendering for every subsequent call in the same request. Verify the behaviour in the package source and its tests before depending on it.
- Is parsedown/laravel compatible with Laravel Octane and Swoole?
- Since 1.2.0 the parser is resolved from the container as a singleton, so under Octane, Swoole, or long-lived queue workers the instance can outlive a single request. Whether that is safe depends on whether per-call arguments change state on the shared instance, and the package does not document Octane support explicitly. Test for state leaking between mixed inline and normal calls, and resolve a fresh instance if you need different parsing modes.
- Do I need to clear compiled views after upgrading to 1.2.0?
- Yes. The @parsedown directive is compiled into cached Blade views, so a directive signature change can leave stale compiled templates after the upgrade. Run php artisan view:clear as part of the deployment. Pair it with php artisan config:clear if you publish or edit the new config file.
- How do I enable safe mode or add custom Parsedown extensions?
- Parsedown supports safe mode and custom extensions, and this integration exposes them through the publishable config file rather than through per-call arguments. Set the relevant options in config/parsedown.php, then clear cached configuration with php artisan config:clear. Read the published stub for exact key names, since the release notes do not list them.
- Is parsedown/laravel actively maintained, and what are the alternatives?
- Maintenance depends on both the parsedown/laravel maintainers and upstream erusev/parsedown, whose release cadence has slowed, so check the GitHub repository for recent activity before adopting. If you want a more actively developed, spec-compliant CommonMark parser with a conservative security posture, league/commonmark is the usual alternative in Laravel applications. For simple, trusted Markdown rendering, this package remains a lightweight option.