Download the PHP package dotkernel/dot-user-agent-sniffer without Composer

On this page you can find all versions of the php package dotkernel/dot-user-agent-sniffer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dot-user-agent-sniffer

dot-user-agent-sniffer

dot-user-agent-sniffer is a wrapper on top of matomo/device-detector

OSS Lifecycle

dot-user-agent-sniffer badges

OSS Lifecycle PHP from Packagist (specify version)

GitHub issues GitHub forks GitHub stars GitHub license

Build Static codecov

SymfonyInsight

Install

You can install this library by running the following command:

composer require dotkernel/dot-user-agent-sniffer

Before adding this library as a dependency to your service, you need to add Dot\UserAgentSniffer\ConfigProvider::class, to your application's config/config.php file.

Usage example

<?php

declare(strict_types=1);

namespace Api\Example\Service;

use Dot\UserAgentSniffer\Data\DeviceData;
use Dot\UserAgentSniffer\Service\DeviceServiceInterface;

/**
 * Class MyService
 * @package Api\Example\Service
 */
class MyService
{
    /** @var DeviceServiceInterface $deviceService */
    protected $deviceService;

    /**
     * MyService constructor.
     * @param DeviceServiceInterface $deviceService
     */
    public function __construct(DeviceServiceInterface $deviceService)
    {
        $this->deviceService = $deviceService;
    }

    /**
     * @param string $userAgent
     * @return DeviceData
     */
    public function myMethod(string $userAgent)
    {
        return $this->deviceService->getDetails($userAgent);
    }
}

When called with an $userAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/78.0.3904.84 Mobile/15E148 Safari/604.1', myMethod($userAgent) returns an object with the following structure:

Dot\UserAgentSniffer\Data\DeviceData::__set_state(array(
    'type' => 'smartphone',
    'brand' => 'Apple',
    'model' => 'iPhone',
    'isBot' => false,
    'isMobile' => true,
    'os' =>
      Dot\UserAgentSniffer\Data\OsData::__set_state(array(
        'name' => 'iOS',
        'version' => '13.2',
        'platform' => '',
    )),
    'client' =>
      Dot\UserAgentSniffer\Data\ClientData::__set_state(array(
        'type' => 'browser',
        'name' => 'Chrome Mobile iOS',
        'engine' => 'WebKit',
        'version' => '78.0',
    )),
))

The above call can also be chained as myMethod($userAgent)->getArrayCopy(), to retrieve the details as an array:

array (
    'type' => 'smartphone',
    'brand' => 'Apple',
    'model' => 'iPhone',
    'isMobile' => true,
    'isBot' => false,
    'os' =>
      array (
        'name' => 'iOS',
        'version' => '13.2',
        'platform' => '',
    ),
    'client' =>
      array (
        'type' => 'browser',
        'name' => 'Chrome Mobile iOS',
        'engine' => 'WebKit',
        'version' => '78.0',
    ),
)

All versions of dot-user-agent-sniffer with dependencies

PHP Build Version
Package Version
Requires php Version ~8.1.0 || ~8.2.0 || ~8.3.0
matomo/device-detector Version ^6.3.0
psr/container Version ^1.1.2
laminas/laminas-stdlib Version ^3.18.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package dotkernel/dot-user-agent-sniffer contains the following files

Loading the files please wait ....