Trying to upgrade my project from L5 to L5.1 and here is incompatibility:
Call to undefined method Illuminate\View\Compilers\BladeCompiler::createPlainMatcher()
Here's the code which cause an exception:
Blade::extend(function($view, $compiler) {
$pattern = $compiler->createPlainMatcher('spaceless');
return preg_replace($pattern, '$1<?php ob_start(); ?>$2', $view);
});
Blade::extend(function($view, $compiler) {
$pattern = $compiler->createPlainMatcher('endspaceless');
return preg_replace($pattern, '$1<?php echo trim(preg_replace(\'/>\s+</\', \'><\', ob_get_clean())); ?>$2', $view);
});
What should I change to make this code working in Laravel 5.1?
I had the same problem. I looked into @lukasgeiter comment and that does work, and I will use that going forward. He is referring to adding a blade directive call to
AppServiceProvider
.I had created a blade specific service provider for my Laravel 5.0 app and have a few custom functions that I didn't want to rewrite so I added the
createOpenMatcher
function my custom BladeServiceProvider.In my case I added it like so.
Hope this helps!