Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Raj34's avatar
Level 1

Error: Call to a member function beginTransaction() on null

I am getting Call to a member function beginTransaction() on null when importing data from Maatwebsite\Excel\Excel in Laravel and MongoDB. It's working fine on local but when I am running it on the server it's showing me this error.

0 likes
6 replies
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

The mongo db driver does not support transactions. Disable them in the config file. First publish it with php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider" --tag=config and then change the handler

'transactions' => [
        'handler' => 'null', //was db. Set to null
    ],
1 like
UmaWorld's avatar

@sinnbeck am getting this error PS C:\xampp\htdocs\redwing-backend-laravel> php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider" --tag=config No publishable resources for tag [config]. Publishing complete.

Chingy's avatar

@UmaWorld Try running php artisan vendor:publish, and in the prompt, search for Excel. it's either Maatwebsite or SpartnerNL the initial directory

UmaWorld's avatar

@chingy asking Which provider or tag's files would you like to publish?: Screenshot 2024-09-11 172441

Sinnbeck's avatar

@UmaWorld Are you absolutely sure you have maatwebsite/excel installed? Check your composer.json

Please or to participate in this conversation.