serbanghita / Mobile-Detect

Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.
http://mobiledetect.net
MIT License
10.55k stars 2.68k forks source link

3.7.4 Compatibility With PHP 8.0+ #961

Open semrocc opened 3 months ago

semrocc commented 3 months ago

As I am not familiar with Composer, and version 4.8 looks overly complicated for myself, a non-programmer, I was wondering if version 3.7.4+ will continue to work with PHP 8.0+

Currently, I have tested version 3.7.4 with PHP 8.3, and there does not appear to be any problems. I would just like to confirm that 3.7.4 will continue to be PHP 8.0+ compatible. Thanks

ryanwhowe commented 1 month ago

@semrocc the documentation shows that the 3.74 version is not intended to support PHP 8 (it states <8.0), so you are in a "use at your own risk" situation. I would consider the 3.74 current composer.json file to have a bug in the required php verison setting. Currently, it shows >= 7.0 while it should be ^7.0 to exclude support for php 8. It appears that you are only able to install it in php 8 via composer due to an oversight in the composer.json setting.

semrocc commented 1 month ago

@ryanwhowe thanks for this information. Currently I only call the MobileDetect.php file and then some variation of:

if ($detect->isMobile() && !$detect->isTablet())

Do you expect that the MobileDetect.php file will continue to work with future versions of PHP 8+?

ryanwhowe commented 1 month ago

@semrocc looking through the code briefly there are no forward issues that I see with php ^8.0 support. At its heart, the package is a header parser with an extensive library of mobile and tablet snippets that indicate different types of browsers. Our usage is similar to yours but we are slowly transitioning to just utilizing css and view ports instead of modifying our backed behavior based on the requester's header browser.

semrocc commented 1 month ago

@ryanwhowe thanks for this information, much appreciated.

Xon commented 1 month ago

The 3.74.x branch works with php 8.0 to php 8.3, but isn't compatible with php 8.4+ (ref #956). Sadly the PR I had for 3.74.x wasn't accepted

semrocc commented 1 month ago

Having the 3.7.4 versions compatible with versions of PHP 8.4+ would certainly be nice for people like myself as Mobile Detect versions 4.8+ will simply not be an option for me.