Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Tex2Png Bundle

Tex2Png Bundle Laravel Package

gregwar/tex2png-bundle

A Symfony bundle that converts LaTeX and TeX markup into PNG images via the tex2png library, with caching and Twig helpers for embedding rendered formulas directly in your templates.

View on GitHub
Deep Wiki
Context7

Symfony2 bundle to generate PNG images from LaTeX math formulas

Frequently asked questions about Tex2Png Bundle
Does gregwar/tex2png-bundle work with Laravel?
No. It is a Symfony2 bundle that registers a Tex2png service in the Symfony DI container and exposes Twig helpers, with no Laravel service provider, facade, config publish tag, or package auto-discovery entry. Laravel will not load or configure it. The only reusable asset is the Gregwar\Tex2pngBundle\Tex2png class, which you can vendor or reimplement.
How do I install gregwar/tex2png-bundle in a Laravel app?
You should not install it in a Laravel app. Its Composer constraints target Symfony 2.x/3.x-era framework-bundle and symfony/process versions, so installation will likely fail against Laravel 10 or 11 without forking or using ignore-platform-reqs. Even if it installs, there is no Laravel integration. Require the underlying gregwar/tex2png library after verifying PHP 8 compatibility, or copy the small Tex2png class into app/Support.
What server dependencies does gregwar/tex2png-bundle require?
It requires the TeX Live binaries latex and dvipng on every node that renders formulas; typical packages are texlive-latex-base, texlive-latex-extra, and dvipng. There is no PHP-only path because it shells out to the native LaTeX toolchain via symfony/process. Plan for immutable container images, explicit timeouts, and a fallback path when rendering fails.
Can I use the Tex2png class without the Symfony bundle in Laravel?
Yes. The Gregwar\Tex2pngBundle\Tex2png class is a small wrapper of roughly 200 lines around latex and dvipng, and it is MIT licensed. Vendor it or copy it into app/Support after validating it under your PHP version. Wrap it behind an application-level TexRenderer interface with a render(string $latex, array $options): string contract so a later swap to KaTeX SSR only changes one binding.
Is gregwar/tex2png-bundle safe for user-supplied LaTeX input?
Treat it as high risk. User-supplied LaTeX passed to a local latex binary enables local file disclosure through input and include commands, shell escape through write18 if enabled, and trivial resource exhaustion with deeply nested or looping constructs. You inherit full liability for sandboxing, timeouts, and input sanitisation. For untrusted input, prefer client-side KaTeX or MathJax rather than server-side LaTeX execution.
How should I cache LaTeX PNG output in Laravel?
Do not rely on the library's local filesystem writes; route storage through Laravel's Storage facade so cached images live on a shared volume or object store instead of a container-local temp directory. Key the cache by a hash such as sha256 of the LaTeX source, dpi, and render options, and set an explicit TTL. For non-trivial volume, render through a queue-backed job rather than synchronously in the request.
What are alternatives to gregwar/tex2png-bundle for rendering LaTeX in Laravel?
For most Laravel applications, client-side KaTeX or MathJax satisfies math rendering at zero infrastructure cost. If you need server-side output without a browser, KaTeX server-side rendering in Node or a MathJax service is a better-maintained option. If you specifically need PNG raster output, wrap the gregwar/tex2png library yourself or use a maintained rendering service rather than an abandoned Symfony bundle.
Is gregwar/tex2png-bundle maintained and compatible with PHP 8 and Laravel 10 or 11?
No. It is an abandoned early-2010s component with very few stars, zero dependents, and no visible maintenance or security advisories. Expect friction with symfony/process version pinning, PHP 8.1+ deprecations such as dynamic properties and implicit nullable parameters, and the absence of Laravel auto-discovery. Assume you own every future fix and budget for a named internal maintainer and a fork in your VCS.
How do I render LaTeX in a Blade template instead of using the bundle's Twig helpers?
The bundle's Twig helpers do not exist in Laravel. Create a Blade directive or, better, resolve a TexRenderer interface from the container and render in a controller or queued job. Pass the resulting image URL or path to the view and let the template output an img tag. Keep rendering out of the Blade template itself so caching, timeouts, and failure handling stay testable.
How do I test LaTeX rendering in a Laravel application?
Unit test the TexRenderer contract with a fake implementation so most tests never invoke real binaries. Add a small integration suite that runs in a disposable container image with texlive-latex-base, texlive-latex-extra, and dvipng installed, and assert correct PNG output, cache hits, timeout behaviour, and the fallback path on render failure. Keep the integration suite out of the default fast test run.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package