raphy/markdown-bundle
A Symfony bundle for working with Markdown in your applications, making it easy to parse and render Markdown content through the framework's service and template layers with minimal configuration.
Before installing, know what you're getting: raphy/markdown-bundle is a Symfony bundle, not a Laravel package. It ships no ServiceProvider, no facade, and no config/markdown.php. It has had no release since June 2018, 4 stars, and 0 dependents — treat it as a dead upstream that wraps an existing Markdown parser (check composer.json for the underlying lib; historical versions wrap michelf/php-markdown / MarkdownExtra).
Step 1 — Evaluate before you commit. Run composer show raphy/markdown-bundle --all and inspect the require block. If it pins PHP 7.x or Symfony 3/4 components, it will fight with a modern Laravel app. If it does, stop here and use league/commonmark (actively maintained, framework-agnostic) or erusev/parsedown directly.
Step 2 — If you proceed, install it and locate the real work. The bundle is thin; the actual Markdown conversion is a service you can instantiate yourself:
composer require raphy/markdown-bundle
Browse vendor/raphy/markdown-bundle/ — look at Resources/config/services.* for the service id and class, and at its composer.json for the parser dependency.
Step 3 — Wire it manually in AppServiceProvider::register():
use Raphy\MarkdownBundle\Service\Markdown; // adjust to actual class name
$this->app->singleton('markdown', fn () => new Markdown());
First real use case: rendering trusted Markdown (READMEs, CMS-authored article bodies, changelogs) into HTML inside a Blade view. Do not start with user-submitted content until you've solved sanitization (see Gotchas).
Blade directive. Once registered as a singleton, expose it as a directive so views stay clean:
// AppServiceProvider::boot()
Blade::directive('markdown', fn ($expr) => "<?php echo app('markdown')->transform($expr); ?>");
<article>{!! @markdown($post->body) !!}</article>
Facade for controllers and jobs.
class Markdown extends Facade {
protected static function getFacadeAccessor() { return 'markdown'; }
}
Render once, cache the HTML. Parsing on every request is wasteful for static content. Store both the raw Markdown and the rendered HTML, and invalidate on save:
protected static function booted()
{
static::saving(function ($post) {
if ($post->isDirty('body')) {
$post->body_html = app('markdown')->transform($post->body);
}
});
}
API responses. Return both body (raw, so clients can re-render) and body_html (for direct consumption) — a common pattern in Laravel JSON resources.
Content pipeline stage. If you're ingesting external content, chain it: strip_tags → markdown → HTMLPurifier::purify. Centralize this in a single MarkdownRenderer service rather than scattering calls.
Testing. Keep a fixture directory of .md inputs and expected .html outputs, and snapshot-test your wrapper — that's the only reliable regression check you'll get from an unmaintained dependency.
php artisan vendor:publish here.michelf/php-markdown passes raw HTML straight through. A <script> in a post body renders as a live script. Always sanitize output with mews/purifier or HTMLPurifier before {!! !!}.{!! ... !!} is required, but it also means everything the parser emits is trusted. Wrap sanitization inside your renderer so no view can forget it.composer require fails on PHP 8, use --ignore-platform-reqs only to inspect, not deploy — or skip the package.MarkdownExtra / the parser's options. Read the upstream docs, not the bundle's (which is a one-page README).app/Support/Markdown/ and drop the dependency, or (c) migrate to league/commonmark (same interface idea, actively maintained, ships a MarkdownConverter you can bind to the container in five lines).style=, id=).league/commonmark and skip this bundle. Reach for raphy/markdown-bundle only if you're maintaining an existing Symfony app that already depends on it, or if you're porting and only need the wrapper class as a reference.How can I help you explore Laravel packages today?