Composer install gives Uncaught TypeError

Viewed 2336

I am facing this error "Uncaught TypeError: Argument 1 passed to Illuminate\Log\Logger ::__construct() must be an instance of Psr\Log\LoggerInterface, instance of Mono log\Logger given," when i run php artisan command. my php version is 7.3.9 enter image description here

2 Answers

I had this issue last night, tried with php 7.3 and 7.4 in the end i just used the latest php 8.1 and this issue went away.

You could try going to illuminate/log/Logger.php and adding use Monolog\Logger as Monolog; at the beginning of the file. After that, change the constructor from this:

    /**
     * Create a new log writer instance.
     *
     * @param  \Psr\Log\LoggerInterface  $logger
     * @param  \Illuminate\Contracts\Events\Dispatcher|null  $dispatcher
     * @return void
     */
    public function __construct(LoggerInterface $logger, Dispatcher $dispatcher = null)
    {
        $this->logger = $logger;
        $this->dispatcher = $dispatcher;
    }

to this:

    /**
     * Create a new log writer instance.
     *
     * @param  \Monolog\Logger  $logger
     * @param  \Illuminate\Contracts\Events\Dispatcher|null  $dispatcher
     * @return void
     */
    public function __construct(Monolog $logger, Dispatcher $dispatcher = null)
    {
        $this->logger = $logger;
        $this->dispatcher = $dispatcher;
    }
Related