Weave Code
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
Laravel Blade

Laravel Blade Laravel Package

spatie/laravel-blade

Add Blade to any PHP project with the standalone Blade engine from Spatie. Compile and render Blade templates outside Laravel, with an easy API, caching support, and configurable view paths—ideal for small apps, packages, or custom tooling.

View on GitHub
Deep Wiki
Context7

Use the Laravel's blade outside Laravel

Frequently asked questions about Laravel Blade
Can I use spatie/laravel-blade in a Symfony or Slim PHP project instead of Twig?
Yes, you can integrate spatie/laravel-blade into Symfony or Slim by configuring it as a custom view engine. It supports Blade’s syntax (e.g., @extends, @section) and can replace Twig for templating. However, you’ll need to manually handle Laravel-specific helpers like `asset()` or `route()` by creating wrapper functions. The package is framework-agnostic and works with any PHP project.
What Laravel versions is spatie/laravel-blade compatible with, and does it support Blade components?
This package is designed to work with Blade templates *outside* Laravel, so it doesn’t depend on Laravel versions. However, it was last updated in 2017 and lacks support for Laravel’s newer Blade features like components or stack inheritance. If you need those, consider alternatives like `illuminate/view` or migrating to a maintained Laravel version.
How do I securely render user-generated content in Blade templates with this package?
Since this package doesn’t include Laravel’s built-in security helpers (e.g., `e()` for escaping), you must manually sanitize dynamic content using PHP’s `htmlspecialchars()` or a wrapper class. Avoid using `@include` with user-provided paths directly, as this could lead to template injection. Always validate and escape variables passed to Blade templates.
Is spatie/laravel-blade suitable for production use, or should I use illuminate/view instead?
This package is lightweight and functional, but its last release was in 2017, meaning it lacks PHP 8.x support and may have compatibility issues with modern Blade features. For production, weigh the risks: if you need active maintenance and security updates, `illuminate/view` (Laravel’s standalone view system) or Twig are safer alternatives. Test thoroughly for edge cases like nested includes or dynamic stacks.
How do I configure custom view paths or caching in spatie/laravel-blade?
You can configure view paths and cache directories via the `Blade::setPaths()` and `Blade::setCachePath()` methods. For example, `Blade::setPaths([base_path('resources/views')])` sets your view directory. Caching is enabled by default in the compiled output directory, but you’ll need to manually clear it (e.g., `Blade::clearCompiled()`). Unlike Laravel, there’s no built-in `view:cache` artisan command.
Will this package work with PHP 8.1 or 8.2, or do I need to fork it?
The package was tested up to PHP 7.x and may not work out-of-the-box with PHP 8.x due to deprecated functions (e.g., `create_function`) or attribute syntax conflicts. You’d need to fork it and update dependencies like `illuminate/compiler` or `illuminate/view` for compatibility. Alternatively, consider `illuminate/view` directly, which is actively maintained for modern PHP.
Can I use Blade components (e.g., `@component('Alert'))` with spatie/laravel-blade?
No, this package does not support Laravel’s Blade components or stack inheritance features introduced in Laravel 7+. Components rely on Laravel’s service container and helper functions, which aren’t available in this standalone package. For components, use `illuminate/view` or migrate to a full Laravel setup.
How do I integrate spatie/laravel-blade with a custom asset pipeline (e.g., Vite or Webpack)?
Since this package doesn’t include Laravel’s `mix()` or `vite()` helpers, you’ll need to manually replace them with your asset pipeline’s directives. For example, use `@vite(['resources/css/app.css'])` directly if your build tool supports it, or create a custom Blade directive to generate asset URLs. Ensure your pipeline processes Blade files if they contain dynamic asset references.
Are there performance concerns with using Blade templates in a high-traffic microservice?
Blade templates compiled by this package are cached like Laravel’s views, reducing runtime overhead. However, dynamic includes (`@include`) or complex layouts may impact performance in high-traffic scenarios. Test under load and consider pre-compiling templates or using a lighter alternative like Twig for microservices. Avoid `@stack` or `@yield` if not needed, as they add complexity.
What alternatives exist if spatie/laravel-blade is too outdated or risky?
For a maintained standalone Blade solution, use `illuminate/view` (Laravel’s view system without the full framework). For other templating engines, consider Twig (active maintenance, flexible) or PHP’s native `extract()` for simple cases. If you need Laravel’s Blade *and* components, use Laravel’s `laravel/framework` or `spatie/laravel-package-tools` for package development. Always evaluate security and PHP version support before choosing.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport