stressed out
stressed out

Reputation: 552

Getting "MongoDB\Driver\Manager Not Found" when using view composers in Laravel

I am using Laravel 7 and Jensseger's MongoDB package. Everything works fine, except for this:

When I issue php artisan view:clear, I get MongoDB\Driver\Manager Not Found error.

I already have installed the latest version of MongoDB module for php 7.4 and everything else works fine. Meanwhile, I am using a dockerized environment. So, I am totally clueless why this is happening when I try to clear cached views.

This is my ViewServiceProvider file:

class ViewServiceProvider extends ServiceProvider
{
    public function register()
    {
    }

    public function boot(HeaderRepository $repository)
    {
        $header = $repository->getHeader();
        View::composer('errors::*', function($view) use($header){
            $view->with([
                'header' => $header,
            ]);
        });
    }
}

My purpose is to create a customized 404 error page, but the header has to be fetched from MongoDB and shared between customized error pages. That's why I'm using view composers. Any other solution is welcome as well.

Upvotes: 0

Views: 192

Answers (1)

Maksim
Maksim

Reputation: 2957

I suppose, you enter command php artisan view:clear from a local console. You have choice:

  1. Install mongo drive to your local interpreter
  2. Use artisan from docker container eg docker exec {PHP_CONTAINER} php artisan view:clear

Upvotes: 1

Related Questions