{"id":15021836,"url":"https://github.com/acsiomatic/device-detector-bundle","last_synced_at":"2025-04-10T20:13:31.366Z","repository":{"id":40445021,"uuid":"316006385","full_name":"acsiomatic/device-detector-bundle","owner":"acsiomatic","description":"Symfony Bundle for https://github.com/matomo-org/device-detector","archived":false,"fork":false,"pushed_at":"2024-11-07T17:12:17.000Z","size":71,"stargazers_count":12,"open_issues_count":4,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T17:54:52.716Z","etag":null,"topics":["bot-detection","detection-library","device-detector","mobile-detection","php","symfony","symfony-bundle","user-agent"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/acsiomatic/device-detector-bundle","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/acsiomatic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-25T17:15:28.000Z","updated_at":"2024-12-23T07:34:46.000Z","dependencies_parsed_at":"2024-01-04T09:47:02.906Z","dependency_job_id":"811bc6c8-d921-4c10-bab2-366a1216fc60","html_url":"https://github.com/acsiomatic/device-detector-bundle","commit_stats":{"total_commits":31,"total_committers":2,"mean_commits":15.5,"dds":"0.12903225806451613","last_synced_commit":"d7041e24b56828d9dfa1ce50f60f7b0e42037387"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acsiomatic%2Fdevice-detector-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acsiomatic%2Fdevice-detector-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acsiomatic%2Fdevice-detector-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acsiomatic%2Fdevice-detector-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acsiomatic","download_url":"https://codeload.github.com/acsiomatic/device-detector-bundle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248288362,"owners_count":21078903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot-detection","detection-library","device-detector","mobile-detection","php","symfony","symfony-bundle","user-agent"],"created_at":"2024-09-24T19:57:07.457Z","updated_at":"2025-04-10T20:13:31.344Z","avatar_url":"https://github.com/acsiomatic.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AcsiomaticDeviceDetectorBundle\n\nThe `AcsiomaticDeviceDetectorBundle` provides integration of the [DeviceDetector][dd] library into the [Symfony][sf] framework.\n\n\u003e [DeviceDetector][dd] is a Universal Device Detection library that parses User Agents and Browser Client Hints to detect devices (desktop, tablet, mobile, tv, cars, console, etc.), clients (browsers, feed readers, media players, PIMs, ...), operating systems, brands and models.\n\u003e\n\u003e From https://github.com/matomo-org/device-detector\n\nThis bundle provides the [`DeviceDetector` class][dd-class] as [service][sf-service], and [Twig global variable][twig-global-variables].\n\n- [Installation](#installation)\n- [Configuration](#configuration)\n- [Usage](#usage)\n  - [Usage in controllers](#usage-in-controllers)\n  - [Usage in Twig](#usage-in-twig)\n  - [Usage in route condition](#usage-in-route-condition)\n  - [Parsing custom request](#parsing-custom-request)\n- [Release Policy](#release-policy)\n  - [Dependencies Compatibility Policy](#dependencies-compatibility-policy)\n\n## Installation\n\nYou can install the bundle using [Composer]:\n\n```bash\ncomposer require acsiomatic/device-detector-bundle\n```\n\n## Configuration\n\nYou can configure the bundle using the `acsiomatic_device_detector` configuration section:\n\n```yaml\n# config/packages/acsiomatic_device_detector.yaml\n\nacsiomatic_device_detector:\n\n    # If true, DeviceDetector will trigger parser() when necessary\n    auto_parse: true\n\n    # Version truncation behavior, it may assume: major, minor, patch, build, or none\n    # By default minor versions will be returned (e.g. X.Y)\n    version_truncation: 'minor'\n\n    cache:\n\n        # If null, it will disable caching\n        pool: 'cache.app'\n\n    bot:\n\n        # If true getBot() will only return true if a bot was detected (speeds up detection a bit)\n        discard_information: false\n\n        # If true, bot detection will completely be skipped (bots will be detected as regular devices then)\n        skip_detection: false\n\n    twig:\n\n        # If null, it will not assign Twig variable\n        variable_name: 'device'\n\n    routing:\n\n        # If null, it will not tag DeviceDetector as routing condition service\n        condition_service_alias: 'device'\n```\n\n## Usage\n\n### Usage in controllers\n\nYou can inject `DeviceDetector` as a service.\nThis bundle sets up an instance of this class according to the configurations under the `acsiomatic_device_detector` section in order to provide information about the main request.\n\n```php\nuse DeviceDetector\\DeviceDetector;\nuse Symfony\\Component\\HttpFoundation\\Response;\n\nclass MyController\n{\n    public function index(DeviceDetector $device): Response\n    {\n        if ($device-\u003eisSmartphone()) {\n            // ...\n        }\n    }\n}\n```\n\n\u003e [!NOTE]\n\u003e You need to call `$device-\u003eparse()` before asking for device's information if `auto_parse` configuration is false.\n\n### Usage in Twig\n\nThe `DeviceDetector` service is assigned to the Twig templates as `device` variable.\n\n```twig\n{% if device.isSmartphone %}\n    {# ... #}\n{% endif %}\n```\n\n### Usage in route condition\n\nThe `DeviceDetector` is tagged as routing condition service.\n\n```php\nuse Symfony\\Component\\HttpFoundation\\Response;\n\nclass MyController\n{\n    #[Route('/page', condition: \"service('device').isSmartphone()\")]\n    public function index(): Response\n    {\n        // this endpoint is available only for smartphone devices\n    }\n}\n```\n\n### Parsing custom request\n\nYou might want to parse other request than the current one.\nThis bundle provides a service that implements [DeviceDetectorFactoryInterface](src%2FContracts%2FDeviceDetectorFactoryInterface.php).\nThis service provides methods that create fresh `DeviceDetector` instances according to the configurations under the `acsiomatic_device_detector` section, but it doesn't attach them to any request.\n\n## Custom parsers\n\nYou can inject custom parsers into `DeviceDetector` by providing them as services.\n\nIf [autoconfigure][sf-autoconfigure] is enabled, the bundle injects custom parsers.\nOtherwise, you need to add the corresponding tag to each custom parsers:\n\n- `acsiomatic.device_detector.bot_parser`\n- `acsiomatic.device_detector.client_parser`\n- `acsiomatic.device_detector.device_parser`\n\n## Release Policy\n\nThere is a **single** maintained branch per time.\nThis branch targets a minor version.\n\nA maintained version reaches its end-of-life when a new minor version is released.\n\n### Dependencies Compatibility Policy\n\nThis library is compatible with maintained versions of\n[PHP][php-versions],\n[Device Detector][dd-versions], and\n[Symfony][sf-versions].\n\n[composer]: https://getcomposer.org/\n[dd-class]: https://github.com/matomo-org/device-detector/blob/master/DeviceDetector.php\n[dd-versions]: https://github.com/matomo-org/device-detector/branches\n[dd]: https://github.com/matomo-org/device-detector\n[php-versions]: https://www.php.net/supported-versions.php\n[sf-autoconfigure]: https://symfony.com/doc/current/service_container.html#the-autoconfigure-option\n[sf-service]: https://symfony.com/doc/current/service_container.html#fetching-and-using-services\n[sf-versions]: https://symfony.com/releases#sf-versions\n[sf]: https://symfony.com/\n[twig-global-variables]: https://symfony.com/doc/current/templates.html#global-variables\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facsiomatic%2Fdevice-detector-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facsiomatic%2Fdevice-detector-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facsiomatic%2Fdevice-detector-bundle/lists"}