Closed AndiLeni closed 1 year ago
Hi. When you have manually deleted something from the vendor folder, you must do
composer dumpautoload
Thanks for the suggestion. Unfortunately, this did not help. I tried using device-detector without composer, but this gave me the same error.
@sanchezzzhak It seems to be a problem with clients hints.
You may reproduce this issue with the following steps:
<?php
require_once 'vendor/autoload.php';
require_once 'device-detector/autoload.php';
use DeviceDetector\ClientHints;
use DeviceDetector\DeviceDetector;
use DeviceDetector\Parser\Device\AbstractDeviceParser;
use DeviceDetector\Yaml\Symfony as SYP;
$userAgent = $_SERVER['HTTP_USER_AGENT']; // change this to the useragent you want to parse
$clientHints = ClientHints::factory($_SERVER); // client hints are optional
$dd = new DeviceDetector($userAgent, $clientHints);
$dd->setYamlParser(new SYP());
$dd->parse();
if ($dd->isBot()) {
// handle bots,spiders,crawlers,...
$botInfo = $dd->getBot();
} else {
$clientInfo = $dd->getClient(); // holds information about browser, feed reader, media player, ...
$osInfo = $dd->getOs();
$device = $dd->getDeviceName();
$brand = $dd->getBrandName();
$model = $dd->getModel();
}
as soon as I change this line
$dd = new DeviceDetector($userAgent, $clientHints);
to
$dd = new DeviceDetector($userAgent);
the error disappears.
It seems like the AppHints parser is not using the correct yaml parser.
Fatal error: Uncaught Error: Class "Spyc" not found in C:\Users\andil\Desktop\Neuer Ordner\device-detector\Yaml\Spyc.php:28 Stack trace: #0 C:\Users\andil\Desktop\Neuer Ordner\device-detector\Parser\AbstractParser.php(252): DeviceDetector\Yaml\Spyc->parseFile('C:\\Users\\andil\\...') #1 C:\Users\andil\Desktop\Neuer Ordner\device-detector\Parser\Client\Hints\AppHints.php(43): DeviceDetector\Parser\AbstractParser->getRegexes() #2 C:\Users\andil\Desktop\Neuer Ordner\device-detector\Parser\Client\MobileApp.php(97): DeviceDetector\Parser\Client\Hints\AppHints->parse() #3 C:\Users\andil\Desktop\Neuer Ordner\device-detector\DeviceDetector.php(858): DeviceDetector\Parser\Client\MobileApp->parse() #4 C:\Users\andil\Desktop\Neuer Ordner\device-detector\DeviceDetector.php(613): DeviceDetector\DeviceDetector->parseClient() #5 C:\Users\andil\Desktop\Neuer Ordner\index.php(19): DeviceDetector\DeviceDetector->parse() #6 {main}
Thanks for the quick fix! :-)
Hello,
I have problems with spyc in my CMS which uses its own autoloader. That’s why I wanted to switch to the Symfony Yaml Parser.
I installed device detector via composer and deleted the mustangostang/spyc folder in /vendor. I then tried to switch to Symfony like this:
Instead a
Class 'Spyc' not found
error is thrown. Any ideas what might be wrong with this approach?Thanks and kind regards