dragon-code/laravel-http-user-agent
Laravel package for reading and interpreting HTTP User-Agent headers. Provides convenient helpers to detect browser, operating system, device type, and bot traffic from incoming requests.
composer require vendor/package; the service provider is auto-discovered on Laravel 5.5+.php artisan vendor:publish --tag=package-config. That file is the source of truth for the options the middleware will apply — read it before reading the code.globalOptions() method is gone in favour of middleware. If your app (or a wrapper package) calls globalOptions() directly, that call is now dead code at best and a fatal error at worst.bootstrap/app.php):
->withMiddleware(function (Middleware $middleware) {
$middleware->append(\Vendor\Package\Middleware\ApplyGlobalOptions::class);
})
Laravel 10 and below: add the class to $middleware (global) or $middlewareGroups['web'] in app/Http/Kernel.php.handle() or asserting on the resulting response.web group when API routes must stay untouched. The middleware approach makes this decision explicit, which is the main win over the old implicit globalOptions() call.$middleware->priority([...]) if auto-ordering puts it in the wrong place.config/package.php and vary them per environment via .env. The middleware reads config at request time, so config:cache in production is fine — just remember to rebuild it on deploy.->withoutMiddleware(ApplyGlobalOptions::class) on the route or group rather than branching inside handle().$this->withMiddleware() to include it in feature tests and assert on the observable effect (headers, resolved options) rather than on the middleware class itself. Use $this->withoutMiddleware() only for tests that are unrelated to option resolution.$this->app->bind(...)) or use $middleware->replace() on Laravel 11+ instead of forking the package.globalOptions() must be removed. Grep for globalOptions across app/, your own packages and any published vendor overrides before deploying.globalOptions() call happened in a service provider, it also affected console commands, queued jobs and scheduled tasks. Those contexts silently lose the behaviour after upgrading. This is the most likely production surprise — audit non-HTTP entry points.withoutMiddleware() in a base test case will disable the new middleware everywhere and your assertions will pass for the wrong reason. Assert the effect at least once with middleware enabled.php artisan optimize:clear; route caching and config caching both hide middleware registration changes and produce confusing "it works in tinker but not in the browser" symptoms.php artisan route:list -v (shows middleware per route) or Telescope's request detail panel, rather than guessing from behaviour.config() in handle(), not in the constructor.How can I help you explore Laravel packages today?