Download the PHP package dfox288/string-blade-compiler without Composer
On this page you can find all versions of the php package dfox288/string-blade-compiler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package string-blade-compiler
String Blade Compiler
Render Blade templates from string value.
Reworked version to allow for array to be passed to the view function instead of template file name.
This is a direct extension of \Illuminate\View\View and is build to replace its usage. It will replace the default View instance.
Versions
String Blade | Laravel Version |
---|---|
8.0 | Laravel 10 |
6.0 | Laravel 8 |
5.0 | Laravel 7 |
4.0 | Laravel 6 |
3.8 | Laravel 5.8 |
3.7 | Laravel 5.7 |
3.6 | Laravel 5.6 |
3.5 | Laravel 5.5 |
3.4 | Laravel 5.4 |
3.3 | Laravel 5.2 |
3.2 | Laravel 5.1 |
2.* | Laravel 5 |
1.* | Laravel 4.2 |
Version 3.8 : Updates
The package has been completely rewritten, all code updated to be more in line with the Laravel version code. Several of the functions in the extended class were not needed and have been removed and the code has been cleaned up a bit.
Also updated the tests to what is available in Laravel View Tests. Some are not applicable to StringBlade.
Changes,
- Now uses Laravel auto registration feature.
- No long need to remove from
- The ability to , , and have been removed from Laravel (https://github.com/laravel/framework/issues/17736). They are depreciated here.
- The compiler function , has been deprecated as I didn't find any code where it was actually being used.
- Added more tests
Installation
Add the package to composer.json:
"require": {
...
"wpb/string-blade-compiler": "VERSION"
},
To get versions 'composer show wpb/string-blade-compiler', such as 'dev-master, * 3.2.x-dev, 3.2.0, 3.0.x-dev, 3.0.0, 2.1.0, 2.0.x-dev, 2.0.0, 1.0.x-dev, 1.0.0'
On packagist.org at https://packagist.org/packages/wpb/string-blade-compiler
composer require "wpb/string-blade-compiler"
Configuration
In config\app.php, providers section:
Both the ServiceProvider and Facade Alias are auto registered by Laravel. There is no need to add them to the /config/app.php file.
Replace 'Illuminate\View\ViewServiceProvider::class' with 'Wpb\String_Blade_Compiler\ViewServiceProvider::class',
This version does not require you to remove the registration of the original view component. Upon ServiceProvider registration it will replace the view binds with its self.
Laravel's Autoloader
There currently is a issue in Laravel's preload process of ServiceProviders. Service providers that are registered with the autoloaded are instantiated before service providers that are set in /config/app.php. This may cause problems in prior versions of StringBladeCompiler. The version has been rewitten to account for the autoloading process.
A pull request that would load vendor service providers registerd in the file before autoloads, was sent to Laravel/Framework and was rejected.
- If you have a need to have this, or any other, package load before the vendor autoloads, do this - https://gist.github.com/TerrePorter/4d2ed616c6ebeb371775347f7378c035
Config
Default cache time for the compiled string template is 300 seconds (5 mins), this can be changed in the config file, env file, or when calling a view. The change is global to all string templates.
STRING_BLADE_CACHE_TIMEOUT=300
Autoloading of blade custom directives can be changed in the config and env files.
STRING_BLADE_AUTOLOAD=false
Note: If using homestead or some other vm, the host handles the filemtime of the cache file. This means the vm may have a different time than the file. If the cache is not expiring as expected, check the times between the systems.
Usage
This package offers a StringView facade with the same syntax as View but accepts a Array or Array Object instance instead of path to view.
New Config Option:
Laravel 5.8 BladeCompiler adds a php comment to the compiled template file . Since StringBladeCompiler does not have a "path" aka "template file location" that would be helpful to the developer. I have included a new config value, . This allows the developer to tag the StringBladeCompiler for where it is used. This is for if you end up digging in to the compiled view files, it would allow you to see a tag for StingBladeCompiler files.
Config Options:
Since StringBlade is a extend class from the original View. You should be able to do anything you would normally do with a View using StringBlade.
Blade::extend, for example :
As the compilers are set up as separate instances, if you need the extend on both the string and file template you will need to attach the extend (or directive) to both compilers.
Other options,
Deleting generated compiled cach view files (v3+).Set the delete flag for the compiler being used, stringblade or blade
I can't seem to find when the setting was actually used. If you want this, submit a bug and I will see about adding the ability.
License
string-blade-compiler is open-sourced software licensed under the MIT license