Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel 5.1 error #7

Open
younes0 opened this issue Jun 9, 2015 · 8 comments
Open

Laravel 5.1 error #7

younes0 opened this issue Jun 9, 2015 · 8 comments

Comments

@younes0
Copy link
Contributor

younes0 commented Jun 9, 2015

With the new release, I get:

FatalErrorException in ViewServiceProvider.php line 64:
Call to undefined method Illuminate\View\Compilers\BladeCompiler::createOpenMatcher()

I'm investigating this

@younes0
Copy link
Contributor Author

younes0 commented Jun 9, 2015

@younes0
Copy link
Contributor Author

younes0 commented Jun 9, 2015

can't get it...

@davidianbonner
Copy link

Hi @younes0,

What problem are you facing? Blade seems to of had a bit of an overhaul with 5.1 and the extend method has been altered. Mainly due to the removal of the create*Matcher methods.

You can get over this with a small change by copying the regex patterns into your own code and do something like this in the service provider for instance:

public function boot()
{
    Blade::extend(function($view, $compiler) {
        $pattern = $this->createMatcher('directiveName');
    });
}

protected function createMatcher($function)
{
    return '/(?<!\w)(\s*)@'.$function.'(\s*\(.*\))/';
}

If however you'd rather upgrade properly, the directive method essentially does some of the heavy lifting for you as seen in the docs. The example in the docs will replace @datetime($foo) with the returned value, saving you from having to do the matching.

@younes0
Copy link
Contributor Author

younes0 commented Jun 11, 2015

Thanks @dbonner1987 for your help,

I used a dirty workaround by duplicating BladeCompiler class and adding the removed create*Matcher methods.

I couldn't convert this to the new format:

return preg_replace(
    $pattern, 
    '$1<?php $__env->renderPartial$2, get_defined_vars(), function($file, $vars) use ($__env) { 
        $vars = array_except($vars, array(\'__data\', \'__path\')); 
        extract($vars); ?>', 
    $value
);

I will look into this further later or make a PR based on your solution:https://github.com/Arrilot/laravel-widgets/blob/master/src/ServiceProvider.php#L119

@crhayes
Copy link
Owner

crhayes commented Jun 15, 2015

I'll try and look into this issue this week. Thanks for the report.

@joelsaxton-zz
Copy link

Is there a cleaner solution to this yet?

@piercemcgeough
Copy link

Had there been any progress on this for Laravel 5.2?
This should be a feature implemented into Blade itself I think

@cipto-hd
Copy link

I have managed relative include using Blade::directive on Laravel 5.4, I think other version 5 may work,

here is the gist

https://gist.github.com/ciptohadi-web-id/91a4ca34ed0f5d1ce15c8a66ee36c284

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants