acasademont/wurfl-bundle
Laravel/PHP bundle integrating the WURFL PHP API for device detection. Use WURFL capabilities in your app to identify phones, tablets, browsers, and other user-agent details and tailor content or features accordingly.
wurfl service in services.yaml).WurflManager or WurflService into controllers/services.config/packages/acf_wurfl.yaml for API keys/local files.{{ app.wurfl.is_tablet }}).wurfl.device_detected).config/packages/acf_wurfl.yaml:
acf_wurfl:
api_key: "%env(WURFL_API_KEY)%"
# OR
local_file: "%kernel.project_dir%/config/wurfl/wurfl.xml"
config/bundles.php:
return [
// ...
Acf\WurflBundle\ACFWurflBundle::class => ['all' => true],
];
WurflManager to fetch device capabilities:
use Acf\WurflBundle\Service\WurflManager;
public function showDeviceInfo(WurflManager $wurfl)
{
$device = $wurfl->getDevice();
return $this->json($device->toArray());
}
wurfl Twig extension:
{% if app.wurfl.is_mobile %}
<link rel="stylesheet" href="{{ asset('css/mobile.css') }}">
{% endif %}
framework.cache: cache.adapter.redis) to cache WURFL responses.try {
$device = $wurfl->getDevice();
} catch (\Exception $e) {
$device = $this->fallbackDeviceDetector->detect();
}
How can I help you explore Laravel packages today?