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

kuschky's avatar

Exception when running php artisan - module mbstring already loaded

Hello, I run Laravel 6.4.1 on Ubuntu 16.04 64bit with php 7.2.24 and Apache 2.4.18. To process an email queue produced by my Laravel application I would like to start a worker with

php artisan -v queue:listen

but it results in an exception

"Symfony\Component\Debug\Exception\FatalThrowableError : Class 'Laravel\Ui\UiServiceProvider' not found"

Even all other php artisan commands fail with the same error.

mbstring is loaded by apaches php.ini

"extension=mbstring.so"

Nows somebody how to solve the error?

Here is the complete output after the exception occurs

root@myhost:/htdocs/mailportal.somedomain.de# php artisan -v queue:listen PHP Warning: Module 'mbstring' already loaded in Unknown on line 0

Symfony\Component\Debug\Exception\FatalThrowableError : Class 'Laravel\Ui\UiServiceProvider' not found

at /var/www/mailportal.somedomain.de/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:742 738| if ($service) { 739| unset($this->deferredServices[$service]); 740| } 741|

742| $this->register($instance = new $provider($this)); 743| 744| if (! $this->isBooted()) { 745| $this->booting(function () use ($instance) { 746| $this->bootProvider($instance);

Exception trace:

1 Illuminate\Foundation\Application::registerDeferredProvider("Laravel\Ui\UiServiceProvider", "Laravel\Ui\AuthCommand") /var/www/mailportal.somedomain.de/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:722

2 Illuminate\Foundation\Application::loadDeferredProvider("Laravel\Ui\AuthCommand") /var/www/mailportal.somedomain.de/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:698

Please use the argument -v to see more details.

Whoops\Exception\ErrorException : Module 'mbstring' already loaded

at Unknown:0 1|

Exception trace:

1 Whoops\Run::handleError("Module 'mbstring' already loaded", "Unknown") /var/www/mailportal.somedomain.de/vendor/filp/whoops/src/Whoops/Run.php:433

2 Whoops\Run::handleShutdown() [internal]:0

0 likes
6 replies
Sinnbeck's avatar

Check your php.ini. Seems you are loading mbstring.so twice (perhaps one of them is via conf.d/20-mbstring

Snapey's avatar

You have a warning about mbstring but the real problem is that the autoloader cannot find Laravel\Ui\UiServiceProvider

My first thought is that perhaps there is a case issue between UI and Ui somewhere

Check the letter case of all things and if you make any changes, remember to run composer dump

kuschky's avatar

Hello Thanks for your help, you were right with both hints. The Exception was produced because laravel/ui was missing on my target system. I'm new to laravel and just installed laravel via composer. On my windows developement system laravel/ui was installed by default. On my Linux target system it was missing. I just add the missing line to my composer.json like I found it on my windows system

    "require-dev": {
        "facade/ignition": "^1.4",
        "fzaninotto/faker": "^1.4",
        "laravel/ui": "^1.1",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^3.0",
        "phpunit/phpunit": "^8.0"
    },

and did a

composer.phar update

composer.phar install

and now it's working :-) Still don't know for what laravel/ui is for but it helped.

The mbstring issue is still there I can't find the module load a second time . Don't know where it comes from.

Thanks again for your help

Snapey's avatar

You should copy composer.lock from your development environment to your production environment, and then run composer install --no-dev

This will install the exact same package versions in production as you have in development.

kuschky's avatar

Why call composer with --no-dev? On my Windows system laravel/ui is in the "require-dev" section of composer.json or do I have to move it to the "require" section?

Snapey's avatar

because laravel/ui should be compiled into your front-end public/css and public/js assets - there should be no need for it in production because you ship the compiled assets

Please or to participate in this conversation.