PHP code example of browscap / browscap-php

1. Go to this page and download the library: Download browscap/browscap-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

browscap / browscap-php example snippets


$cache = new \MatthiasMullie\Scrapbook\Psr16\SimpleCache($doctrineFileCache); // or maybe any other PSR-16 compatible caches
$logger = new \Monolog\Logger('name'); // or maybe any other PSR-3 compatible logger

$browscap = new \BrowscapPHP\Browscap($cache, $logger);
$info = $browscap->getBrowser();

vendor/bin/browscap-php browscap:fetch
vendor/bin/browscap-php browscap:convert

vendor/bin/browscap-php browscap:update

$fileCache = new \League\Flysystem\Local\LocalFilesystemAdapter($cacheDir);
$filesystem = new \League\Flysystem\Filesystem($fileCache);
$cache = new \MatthiasMullie\Scrapbook\Psr16\SimpleCache(
    new \MatthiasMullie\Scrapbook\Adapters\Flysystem($filesystem)
);

$logger = new \Monolog\Logger('name');

$bc = new \BrowscapPHP\Browscap($cache, $logger);
$result = $bc->getBrowser();

$bc = new \BrowscapPHP\BrowscapUpdater();
$bc->update(\BrowscapPHP\Helper\IniLoaderInterface::PHP_INI_FULL);

$proxyConfig = [
    'proxy' => [
        'http'  => 'tcp://localhost:8125',
        'https' => 'tcp://localhost:8124',
    ],
];
$client = new \GuzzleHttp\Client($proxyConfig);
$bcu = new BrowscapUpdater();
$bcu->setClient($client);

$bc = new \BrowscapPHP\Browscap();
$current_browser = $bc->getBrowser();

$bc = new \BrowscapPHP\Browscap($cache, $logger);
$current_browser = $bc->getBrowser($the_user_agent);

vendor/bin/browscap-php browscap:check-update

vendor/bin/browscap-php browscap:fetch

vendor/bin/browscap-php browscap:convert

vendor/bin/browscap-php browscap:update

vendor/bin/browscap-php browscap:parse

vendor/bin/browscap-php browscap:update --remote-file Full_PHP_BrowscapINI

vendor/bin/browscap-php browscap:update --cache ./browscap-cache
shell
composer