2017 © Pedro Peláez
 

october-plugin agent-plugin

Detect user's browser, OS, and device from UserAgent. A wrapper plugin of jenssegers/agent.

image

pikanji/agent-plugin

Detect user's browser, OS, and device from UserAgent. A wrapper plugin of jenssegers/agent.

  • Saturday, December 16, 2017
  • by pikanji
  • Repository
  • 1 Watchers
  • 2 Stars
  • 125 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 155 % Grown

The README.md

OctoberCMS Agent Plugin

日本語版はこちら, (*1)

OctoberCMS plugin to detect user's browser, OS, and device. This is available not only from PHP but also from Twig templates., (*2)

This is a wrapper plugin of jenssegers/agent. Thanks to jenssegers, and also serbanghita created it's base serbanghita/Mobile-Detect., (*3)

API

Please refer jenssegers/agent for available APIs., (*4)

Usage

Installation

You can install this plugin either via composer or from the backend UI., (*5)

With Composer

Execute below at the root of your project., (*6)

composer require pikanji/agent-plugin

With OctoberCMS UI

  • Login to OctoberCMS backend
  • Go to Settings > Update & Plugins.
  • Click "Install plugins" button.
  • Search for "Agent", and select it to start installation.

Using in Twig Templates

Agent object will be available after Agent component is added to pages or layouts. I recommend to add the component to your layout, so that you don't have to add every page., (*7)

Preparation is to add [Agent] to the configuration section of page or layout files. There is no parameter needed for Agent component., (*8)

description = "Default layout"

[Agent]
==
<!DOCTYPE html>
...

Then you can use this Agent object to call jenssegers/agent APIs., (*9)

...
{% if Agent.isFireFox() %}
...

Using in PHP Code

Add use Agent;, and call methods from Agent facade., (*10)

use Agent;
...

if (Agent::isFireFox()) {
...

If you don't want to use facade, you can use it like this., (*11)

use Jenssegers\Agent\Agent;
...

$agent = new Agent();
if ($agent->isFireFox()) {
...

It is just using jenssegers/agent directly. Please refer to its documentation. You don't need to install it since it is installed as the dependency of this plugin., (*12)

The Versions

16/12 2017

dev-master

9999999-dev

Detect user's browser, OS, and device from UserAgent. A wrapper plugin of jenssegers/agent.

  Sources   Download

MIT

The Requires

 

by Kanji Furuhashi