jaybizzle / laravel-crawler-detect
A Laravel package to detect web crawlers via the user agent
Installs: 1 794 739
Dependents: 24
Suggesters: 0
Security: 0
Stars: 311
Watchers: 13
Forks: 30
Open Issues: 3
Requires
- php: >=5.4.0
- jaybizzle/crawler-detect: 1.*
Requires (Dev)
- orchestra/testbench: ^3.2|^3.4
- phpunit/phpunit: ^4.8|^5.5|^6.5
This package is auto-updated.
Last update: 2024-11-06 15:45:55 UTC
README
A Laravel wrapper for CrawlerDetect - the web crawler detection library
Installation
Run composer require jaybizzle/laravel-crawler-detect 1.*
or add "jaybizzle/laravel-crawler-detect": "1.*"
to your composer.json
file.
The last version compatible with Laravel 4 was v1.0.2 so if you need that, you will have to fix your composer.json
to that specific version.
Add the following to the providers
array in your config/app.php
file..
Jaybizzle\LaravelCrawlerDetect\LaravelCrawlerDetectServiceProvider::class,
...and the following to your aliases
array...
'Crawler' => Jaybizzle\LaravelCrawlerDetect\Facades\LaravelCrawlerDetect::class,
Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.
Usage
use Crawler; // Check current 'visitors' user agent if(Crawler::isCrawler()) { // true if crawler user agent detected } // Pass a user agent as a string if(Crawler::isCrawler('Mozilla/5.0 (compatible; aiHitBot/2.9; +https://www.aihitdata.com/about)')) { // true if crawler user agent detected }