Slim Application Error - Class ‘Slim\Http\MobileRequest’ not found

Hi,

I’m sorry if this might look like an unnecessary question, but I’m totally new to PHP based stuff and quite new to web development in general. I got a task to make a website work again, which returns the following error message, when trying to visit it. I couldn’t figure out what the problem is. The project was done with Slim 3. Would an upgrade to Slim 4 maybe help?
Thanks.

Slim Application Error
The application could not run because of the following error:

Details
Type: Error

Message: Class ‘Slim\Http\MobileRequest’ not found

File: /is/htdocs/…/src/middleware.php

Line: 32

Trace

#0 [internal function]: Closure->{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#1 /is/htdocs/…/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array(Object(Closure), Array)
#2 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#3 /is/htdocs/…/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#4 /is/htdocs/…/src/middleware.php(40): Slim\App->Slim{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))
#5 [internal function]: Closure->{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#6 /is/htdocs/…/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array(Object(Closure), Array)
#7 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#8 /is/htdocs/…/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#9 /is/htdocs/…/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\App->Slim{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))
#10 /is/htdocs/…/vendor/slim/slim/Slim/App.php(392): Slim\App->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))
#11 /is/htdocs/…/vendor/slim/slim/Slim/App.php(297): Slim\App->process(Object(Slim\Http\Request), Object(Slim\Http\Response))
#12 /is/htdocs/…/index.php(55): Slim\App->run()
#13 {main}

Hi Bob!

The class Slim\Http\MobileRequest does not belong to any Slim Framework version, but I found this class in the zguillez/slim-mobile-detect package.

To fix this, you could just run composer install to install all missing packages and to update the autoloader.

If this does not work, try to install the package with this command: composer require zguillez/slim-mobile-detect

Hi Odan,

Thank you for your help! A few days ago I tried composer update, but revoked it.
Now I had to perform composer update first before composer install. Composer install alone couldn’t be implemented. After composer update and composer install the same error message appeared so I tried composer require zguillez/slim-mobile-detect. unfortunately the error message still occurs.