Error message when adding barryvdh/laravel-dompdf package to composer.json

I am trying to develop a plugin. When I add barryvdh/laravel-dompdf with the command

composer require barryvdh/laravel-dompdf

to the composer.json file, I get the error message

PHP Fatal error: Class Illuminate\Support\MessageBag contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Illuminate\Contracts\Support\MessageBag::forget) in /var/www/html/vendor/laravel/framework/src/Illuminate/Support/MessageBag.php on line 11

Any idea why I am getting this error message? And how can I fix this problem?

Edit

Just additional information: This package was the first package I am adding to the plugin composer.json. When I delete the vendor folder of the plugin, I can access the backend of OctoberCMS like before. But when I call again the command composer install on the plugins composer.json, which downloads the dependencies again, I get the error message above.

Hi @kstarkloff

This looks like the dompdf version isn’t compatible with the Laravel version October is using. What version of October CMS and laravel-dompdf are you using?

Regarding to the command php artisan october:about, my OctoberCMS version is 3.4:

  Environment ......................................................................................................................................  
  Application Name ..................................................................................................................... October CMS  
  Laravel Version .......................................................................................................................... 9.52.10  
  PHP Version ................................................................................................................................ 8.1.6  
  Composer Version ........................................................................................................................... 2.5.8  
  Environment ................................................................................................................................ local  
  Debug Mode ............................................................................................................................... ENABLED  
  URL .................................................................................................................................... localhost  
  Maintenance Mode ............................................................................................................................. OFF  

  Cache ............................................................................................................................................  
  Config ................................................................................................................................ NOT CACHED  
  Events ................................................................................................................................ NOT CACHED  
  Routes ................................................................................................................................ NOT CACHED  
  Views ................................................................................................................................. NOT CACHED  

  Drivers ..........................................................................................................................................  
  Broadcasting .............................................................................................................................. pusher  
  Cache ....................................................................................................................................... file  
  Database ................................................................................................................................... mysql  
  Logs ...................................................................................................................................... single  
  Mail ......................................................................................................................................... log  
  Queue ....................................................................................................................................... sync  
  Session ..................................................................................................................................... file  

  October CMS ......................................................................................................................................  
  October CMS Version .......................................................................................................................... 3.4  
  Plugin Updates Count ........................................................................................................................... 0  

I am using the docker image octobercms/october-dev:latest for developing my plugin.

According to composer.lock I am using the laravel-dompdf version v2.0.1.

So, the error disappears when I install the version v2.0.0 of laravel-dompdf with

composer require barryvdh/laravel-dompdf:v2.0.0
1 Like

I’ve got the same problem with the spatie/laravel-sitemap package. When requiring it inside a plugin, the Messagebag error pops up, but this isn’t the case when it’s installed in the application.