'Class 'Spatie\YamlFrontMatter\YamlFrontMatter' not found

I need help. I installed Yaml-front-matter via composer, everything was good. But if I use this class in my project, I get this very strange error. Why laravel doesn't see this class? I do not find a solution with google.

I tried commands: php artisan optimize: clear, composer dump-autoload but they don't help.

Thanks in advance.

screen to show the problem



Solution 1:[1]

Replace this

$document = YamlFrontMatter::parseFile(resource_path('posts/my-fourth-post.html'); 

with this

$document = \Spatie\YamlFrontMatter\YamlFrontMatter::parseFile(resource_path('posts/my-fourth-post.html'); 

It works.

Source: https://laracasts.com/discuss/channels/laravel/class-yamlfrontmatter-not-found-laravel-docker-composer

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Michal