helsingborg-stad/blade
Larablocks Analysis
helsingborg-stad/blade works with Laravel 8 (latest release 3.5.2, Nov 6, 2026), which reached end of life on Jan 24, 2023: no more fixes, even for security.
Laravel 5, 6 and 7 in earlier releases.
Recommendation checks
Use with careUse with care: meets 1 of 4 checks.
- Supports only Laravel 8, past end of life since Jan 24, 2023
- Released in the last 12 months (Nov 6, 2026)
- 3,409 downloads a month (needs 10,000)
- 5 GitHub stars (needs 100)
State
Maintained- Last stable release: Nov 6, 2026.
- 1 release in the last 12 months.
- First released: Mar 14, 2023.
- Monthly downloads: 3,409, up 275% from six months ago.
- 0 open issues on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Dec 2, 2026.
| Install | |
|---|---|
composer require helsingborg-stad/blade |
|
| Latest Version: | 3.5.2 |
| PHP: | ^7.4|^8.0 |
| Laravel: | 8 |
| Older releases: | 5 · 6 · 7 |
| License: | MIT |
| Last Updated: | Nov 6, 2026 |
| Links: | GitHub · Packagist |
Blade
Use Laravel Blade in any PHP project.
If you don't know about Blade yet, please refer to the official documentation.
Requirements
- PHP ^7.4 | ^8.0
- Composer
Installation
composer require helsingborg-stad/Blade
Usage
Configuration
Cache path
- The cache path can be set by passing the path to the constructor of the BladeService.
- If no cache path is set, the Blade Service will use the system's temporary directory.
- The cache path can be overriden by defining the
BLADE_CACHE_PATHenvironment constant.
Initialize blade engine:
This can be done either as a local instance or as a global reusable instance. The global instance is recommended better performance and less memory usage.
Locally
$viewPaths = ['path/to/view/files'];
$cachePath = 'path/to/cache/files';
$bladeService = new BladeService($viewPaths, $cachePath);
Globally (for convenient reuse)
$viewPaths = ['path/to/view/files'];
$cachePath = 'path/to/cache/files';
$bladeService = GlobalBladeService::getInstance($viewPaths, $cachePath);
// You can now reuse the same instance by calling:
$sameInstance = GlobalBladeService::getInstance($viewPaths, $cachePath);
[!NOTE] If calling
GlobalBladeService::getInstancewith parameters after the first call, the $viewPaths will be added and the $cachePath parameter will be ignored.
Render view
$viewFile = 'foo.blade.php';
$html = $bladeService->makeView($viewFile)->render();
Render view with variables
$viewFile = 'foo.blade.php';
$html = $bladeService->makeView($viewFile, ['name' => 'John Doe'])->render();
Render with specific view path
This enables you to temporarily use a specific view path without storing it in the Blade Service.
$viewFile = 'foo.blade.php';
$html = $bladeService->makeView($viewFile, ['name' => 'John Doe'], [], 'specific/view/path')->render();
Register a custom directive
$bladeService->registerDirective('datetime', function ($expression) {
return "<?php echo with({$expression})->format('F d, Y'); ?>";
});
// The directive can now be used by adding the @datetime directive to a view file.
Register a component
$bladeService->registerComponent('foo', function ($view) {
$view->with('name', 'John Doe');
});
// The component can now be used by adding @component('foo')@endcomponent to a view file.
Register a component directive
If you have already registered a component. That component can be added as a directive by doing the following:
$bladeService->registerComponentDirective('componentname', 'directivename');
// This will register a directive that can be used by adding @directivename()@enddirectivename to a view file, and it will output the component.
Add additional view file paths
If you need to add more view file paths after initializing the Blade Service, this can be done by calling BladeService::addViewPath
$bladeService->addViewPath('extra/view/path');
Prepend view file paths
If you need to add more view file paths before the existing view file paths, this can be done by calling BladeService::prependViewPath with the second parameter set to true.
$bladeService->prependViewPath('extra/view/path', true);
[!IMPORTANT] For every unique view path added, performance will be affected. This is due to the fact that the Blade Service will have to search through all view paths to find the correct view file. Therefore, it is recommended to add as few view paths as possible.
Error handling
This package offers a convenient solution for swiftly addressing issues that arise within a function called in a view or a syntax error directly within a file. It provides a function to visually display the error, which proves particularly useful during the development process. To optimize development speed and efficiency, it's advisable to implement an error handler when invoking makeView, ensuring smooth troubleshooting whenever errors occur.
try {
return $bladeService->makeView($viewFile, ['name' => 'John Doe'], [], 'specific/view/path')->render();
} catch (Throwable $e) {
$bladeService->errorHandler($e)->print();
}
Testing
Unit tests
composer test
Code coverage
composer test:coverage
Related Packages
Blazing fast Views with model-driven approach, Blade and multi-namespace support...
Laravel CRUD generator: Generate CRUD for any db table with the crud:generate co...
Laravel Blade String Compiler, render string as blade templates
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 3.5.2 | ^7.4| | ^8.0.0 | MIT | |
| 3.5.1 | ^7.4| | ^8.0.0 | MIT | |
| 3.5.0 | ^7.4| | ^8.0.0 | MIT | |
| 3.4.4 | ^7.4| | ^8.0.0 | MIT | |
| 3.4.3 | ^7.4| | ^8.0.0 | MIT | |
| 3.4.2 | ^7.4| | ^8.0.0 | MIT | |
| 3.4.1 | ^7.4| | ^8.0.0 | MIT | |
| 3.4.0 | ^7.4| | ^8.0.0 | MIT | |
| 3.3.0 | ^7.4| | ^8.0.0 | MIT | |
| 3.2.0 | ^7.4| | ^8.0.0 | MIT | |
| 3.1.0 | ^7.4| | ^8.0.0 | MIT | |
| 3.0.1 | ^7.4| | ^8.0.0 | MIT | |
| 2.0.0 | ^8.3 | 8.* | MIT | |
| 1.0.0 | 5.6.*| | 5.*| | MIT |