alikdex / yii2-crawler-detect

用于CrawlerDetect库的Yii2扩展

1.0 2016-08-03 12:10 UTC

This package is auto-updated.

Last update: 2024-09-17 10:53:43 UTC


README

CrawlerDetect库提供的Yii2扩展。

要使用它,只需在您的composer.json文件中引入此扩展

"alikdex/yii2-crawler-detect": "1.0",

然后将其添加到Yii2的组件配置中

'bootstrap' => ['crawlerdetect'],
'components' => [
	'crawlerdetect' => [
		'class' => 'alikdex\crawlerdetect\CrawlerDetect',
		'setParams' => true, // optional, bootstrap initialize requred
	],
]

一些基本检测可以在Yii的params中找到

var_dump(Yii::$app->params['isCrawler']);

// bool(false)

您也可以在代码的任何地方使用它,调用Crawler-Detect的API

\Yii::$app->crawlerdetect->isCrawler();

/*Check all available methods here: https://github.com/JayBizzle/Crawler-Detect */