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
String Blade Compiler

String Blade Compiler Laravel Package

wpb/string-blade-compiler

Compile Blade template strings at runtime in Laravel. Render Blade syntax stored in databases, variables, or plain strings without creating view files, while keeping familiar directives and cached compiled output for fast, flexible dynamic templating.

View on GitHub
Deep Wiki
Context7

wpb/string-blade-compiler lets you render Blade templates from plain strings instead of view files. It's ideal for templates stored in a database, generated at runtime, or edited by users — such as emails, notifications, and CMS content.

It wraps Laravel's BladeCompiler behind a simple facade, so all native Blade syntax and directives work as usual, while compiled templates are cached for speed.

  • Render Blade strings with StringBlade::renderString($template, $data)
  • Supports the full set of native Blade directives
  • Caches compiled templates for fast repeated renders
  • Seamless Laravel integration via service provider and facade
  • Perfect for database- or user-driven templates
Frequently asked questions about String Blade Compiler
How do I install wpb/string-blade-compiler in Laravel?
Install it with Composer using composer require wpb/string-blade-compiler. Laravel package auto-discovery registers the service provider, so most projects need no manual bootstrap wiring. Run your test suite immediately after installation because the package augments the container's ViewFinder and can affect view resolution globally.
How do I render a Blade template stored in a database column?
Use the package's string-rendering API to compile and render the Blade syntax you loaded from the database column, passing your data array or view variables. This avoids writing temporary view files for admin-editable email, notification, or white-label content. Treat the stored template as trusted code, because compiled Blade is executed as PHP.
Does wpb/string-blade-compiler support Laravel 10 and 11?
The last release was 2020-12-18, and there is no evidence of validation against Laravel 10, 11, or 12, or PHP 8.3 and 8.4. PHP 8.2+ dynamic-property deprecations are a plausible breakage. Prove compatibility in a short spike before committing to it, and prefer Laravel's native Blade::render() on 9.36 and newer.
What is the difference between this package and Laravel's Blade::render()?
Laravel 9.36 and later ship a first-party Blade::render($string, $data) API maintained by the core team, without global view-finder interception. This package predates that API and adds ViewFinder-level hooks, such as loading sub-templates from strings and registering custom directives against string views. For greenfield modern Laravel work, the native API is usually the right architectural choice.
Is eval() in wpb/string-blade-compiler a security risk?
Yes. Rendering is implemented by eval() of compiled PHP, which is remote code execution by design. The critical control is the trust boundary on template authors: if customers or support tools can write template content, that becomes a server-compromise vector. Many SAST and SCA pipelines flag eval(), and some organizations prohibit it, so get security review approval before adopting it.
Can I use wpb/string-blade-compiler with Lumen?
It is described for Laravel 6 through 8 and Lumen estates, and it requires an Illuminate container. Teams running Symfony-only stacks or standalone templating services cannot use it. In Lumen, verify the view bindings and register the provider manually because Lumen does not use Laravel's package auto-discovery by default.
Will this package affect my normal file-based views and mailables?
It can, because it augments the container's ViewFinder so string templates resolve, which means it is not a passive leaf dependency. Test normal file views, namespaced and package views such as vendor::name, mailables and Markdown mail, and any third-party packages that register view paths. Do that verification before rollout rather than after a subtle rendering regression.
Does it support caching, custom directives, and sub-template includes?
The package advertises familiar Blade directives, caching, and a simple API, with finder-level hooks for loading sub-templates from strings and registering custom directives against string views. Confirm the exact behavior for your pinned version, because the last release is from 2020. Decide early whether you need those finder hooks or only basic string compilation.
Is wpb/string-blade-compiler actively maintained?
The last release was 2020-12-18, and it has 172 stars with zero registered Packagist dependents, which signals a small, low-ecosystem-support utility rather than broad validation. The Composer name wpb/string-blade-compiler differs from the TerrePorter/StringBladeCompiler repository, indicating a community continuation, so confirm exactly what you are installing and whether the fork is active. If upstream stays dormant, name an internal owner and budget for upgrades.
What are the alternatives to wpb/string-blade-compiler?
For Laravel 9.36 and newer, use the native Blade::render() method first. For older Laravel or Lumen estates, this package or a similar string-Blade compiler may still be justified. If templates can be authored by tenants or end users, evaluate a sandboxed engine such as Twig's sandbox extension or Liquid instead of in-process eval().
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