device-detector을 사용하여 장치 검색 시스템을 설정하려고합니다. 내가 그것을 설정하는 동안 오류가 점점 그 설명서를 따르고 있습니다. 작곡가를 사용하여 필요한 파일을 다운로드했습니다. 필자는 repo를 복제하여 필요한 파일을 다운로드하고이를 공급 업체의 별도 폴더에 보관했습니다.PSR-4를 사용하여 클래스를 자동로드하는 방법은 무엇입니까?
질문 : 프로젝트 요구 사항에 piwik/device-detector를 추가하기 만하면됩니다. 그러나 실행시 오류가 발생합니다.
공지 사항 : 정의되지 않은 변수 : C에서의 userAgent : \ WAMP \ www가 \ trackme \ track.php
주 라인 11 : 나는 자동 로딩 비교적 새로운 오전.
COMPOSER.JSON
{
"name": "piwik/device-detector",
"type": "library",
"description": "The Universal Device Detection library, that parses User Agents and detects devices (desktop, tablet, mobile, tv, cars, console, etc.), clients (browsers, media players, mobile apps, feed readers, libraries, etc), operating systems, devices, brands and models.",
"keywords": ["useragent","parser","devicedetection"],
"homepage": "http://piwik.org",
"license": "LGPL-3.0+",
"authors": [
{
"name": "The Piwik Team",
"email": "[email protected]",
"homepage": "http://piwik.org/the-piwik-team/"
}
],
"support": {
"forum": "http://forum.piwik.org/",
"issues": "https://github.com/piwik/device-detector/issues",
"wiki": "http://dev.piwik.org/",
"source": "https://github.com/piwik/piwik"
},
"autoload": {
"psr-4": { "DeviceDetector\\": "piwik/device-detector" }
},
"require": {
"php": ">=5.3.2",
"mustangostang/spyc": "*"
},
"require-dev": {
"phpunit/phpunit": "4.1.*",
"fabpot/php-cs-fixer": "~1.7"
},
"suggest": {
"doctrine/cache": "Can directly be used for caching purpose"
}
}
track.php [업데이트]를
<?php
//date_default_timezone_set('Asia/Kolkata');
require_once 'vendor/autoload.php';
use DeviceDetector\DeviceDetector;
use DeviceDetector\Parser\Device\DeviceParserAbstract;
DeviceParserAbstract::setVersionTruncation(DeviceParserAbstract::VERSION_TRUNCATION_NONE);
$dd = new DeviceDetector($userAgent);
$dd->discardBotInformation();
$dd->skipBotDetection();
$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->getDevice();
$brand = $dd->getBrand();
$model = $dd->getModel();
}
echo $osInfo;
}
파일'trackme \ track.php'과'$ userAgent'가 오는 곳에서 12 행과 14 행을 보여줍니다. – Justinas
@Justinas $ userAgent는 다운로드 한 라이브러리의 클래스 파일에서옵니다. – Ayan