Download the PHP package helsingborg-stad/blade without Composer
On this page you can find all versions of the php package helsingborg-stad/blade. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download helsingborg-stad/blade
More information about helsingborg-stad/blade
Files in helsingborg-stad/blade
Package blade
Short Description Use Laravel Blade in any PHP project.
License MIT
Homepage https://github.com/helsingborg-stad/blade
Informations about the package blade
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
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_PATH
environment 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
Globally (for convenient reuse)
[!NOTE] If calling
GlobalBladeService::getInstance
with parameters after the first call, the $viewPaths will be added and the $cachePath parameter will be ignored.
Render view
Render view with variables
Render with specific view path
This enables you to temporarily use a specific view path without storing it in the Blade Service.
Register a custom directive
Register a component
Register a component directive
If you have already registered a component. That component can be added as a directive by doing the following:
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
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
.
[!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.