WhichBrowser / Parser-PHP

Browser sniffing gone too far — A useragent parser library for PHP
http://whichbrowser.net
MIT License
1.79k stars 242 forks source link

Incompatability with automattic/jetpack-autoloader #679

Closed vladlu closed 3 months ago

vladlu commented 1 year ago

I have installed automattic/jetpack-autoloader (v2.11.16) for my wordpress plugin (de-facto a standard and used by many WP plugins (WooCommerce with millions of users)).

And I have also installed your package (jeremykendall/php-domain-parser) of the latest version v2.1.7.

Your plugin has specified

"autoload": {
    "psr-4": {
        "WhichBrowser\\": [ "src/", "tests/src/" ]
    }
},

In composer.json

Which leads to error like this when I try to install the package:

Generating optimized autoload files

In ClassMapGenerator.php line 73:

Could not scan for classes inside "/home/zxc/PhpstormProjects/woosearchandfilter/web/app/plugins/first-party-analytics/vendor/whichbrowser/parser/tests/src" which does not appear to be a file nor a folder

Maybe you could suggest how can I solve this smartly?

jeherve commented 1 year ago

Related discussion: https://github.com/WhichBrowser/Parser-PHP/pull/130#issuecomment-561421839

Would it be an option to not autoload the tests there, since they're not shipped with the production version of the package?

Maybe something like this could work? #680

Note that I'm not familiar with this package, so this may be a bad idea. :)

uuf6429 commented 1 year ago

@jeherve is right, that's exactly how it should be if that code is only needed during development.