- How do I install rmunate/agent-detection in a Laravel app?
- Install it with Composer using composer require rmunate/agent-detection. The package is described as zero-config, with no service provider registration or config publishing required beyond Laravel's auto-discovery. It is MIT licensed and pulls in no infrastructure, database, or credential setup, so you can start calling its detection methods immediately after the autoloader is regenerated.
- Does rmunate/agent-detection work with plain PHP, or only Laravel?
- It is a PHP package distributed via Composer, so it can be used in plain PHP projects as long as you autoload its classes. Laravel-specific conveniences such as facades or Blade usage apply only inside a Laravel application. If part of your stack runs on Node, Go, or legacy scripts outside Composer, you would need a separate solution for those paths.
- How do I detect whether a visitor is a bot or crawler?
- The package parses the incoming User-Agent header and exposes flags that tell you whether the agent looks like a bot, spider, or crawler. You typically call this from middleware, a controller, or a request-scoped helper and branch on the result. Treat the answer as a best-effort heuristic rather than a verified identity, since any client can send an arbitrary UA string.
- Can I tell if a visitor is on a mobile device or desktop?
- Yes. The library returns device class, platform and operating system, and browser family derived from the User-Agent string. That makes it suitable for soft personalization such as showing an app download banner, switching layouts, or choosing a default view. Because it is UA-string based, tablets, unusual enterprise agents, and privacy-hardened browsers may be classified imprecisely.
- Is UA-based bot detection safe to use for rate limiting, access control, or fraud checks?
- No. User-Agent strings are self-reported and trivially spoofed, so heuristic detection produces both false positives and false negatives. A bot can present a mainstream Chrome UA, and legitimate clients with non-standard agents can be misread as bots. Use this package for soft personalization only, and rely on server-side signals such as IP reputation, request behavior, and authentication for anything security-bearing.
- Does rmunate/agent-detection support User-Agent Client Hints like Sec-CH-UA?
- The package is documented as parsing the User-Agent string, and there is no stated support for the Sec-CH-UA, Sec-CH-UA-Mobile, or Sec-CH-UA-Platform headers. That matters because modern Chromium browsers increasingly reduce UA-string fidelity in favor of Client Hints. If accurate browser or platform detection is business critical, verify Client Hints support in the source before committing, or read those headers yourself alongside the package.
- Can I pass a custom User-Agent string when testing detection logic?
- Testing is the main thing to confirm before you standardize on this package. If its detection methods are hard-wired to the current request, you cannot easily assert output for a given UA string in unit tests. Wrap the package behind a small interface of your own and inject the UA string, so your test suite depends on your adapter rather than the vendor's request handling.
- Does the package call an external API or need a database?
- No. Detection is performed locally by parsing the User-Agent string, with no external service calls, API keys, credentials, or database tables involved. That keeps latency negligible and removes the usual failure modes of a network dependency. The only realistic failure is a UA string that parses poorly, which degrades gracefully to default values.
- Which PHP and Laravel versions does rmunate/agent-detection support?
- The supported PHP and Laravel version ranges are declared in the package's composer.json, so check that file against your own platform constraints rather than assuming. Because detection rule sets can change between releases, also pin the version in composer.json and review changelogs before upgrading. A minor version bump can alter classification output even when your application code is untouched, so treat detection-behavior changes as potentially breaking.
- How does it compare to jenssegers/agent or matomo/device-detector?
- jenssegers/agent wraps the Mobile Detect library with a Laravel facade, while matomo/device-detector ships a much larger, regularly updated rule set and can also read Client Hints. rmunate/agent-detection positions itself as a lightweight, single-responsibility parser with a simple API and no external calls. If you need maximum accuracy or long-term rule-set freshness, benchmark all three against your real traffic; if you only need soft device and bot hints, the lighter option may be enough.