Skip to content

Commit 2d29535

Browse files
Merge pull request #4 from dutchenkoOleg/master
readme upd
2 parents 0329dfd + 8a4082d commit 2d29535

File tree

1 file changed

+142
-2
lines changed

1 file changed

+142
-2
lines changed

README.md

Lines changed: 142 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,150 @@
11
# Browserizr PHP
22

33
[![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/dutchenkoOleg/node-w3c-validator/blob/master/LICENSE)
4+
[![WezomAgency](https://img.shields.io/badge/composer-require-orange.svg)](https://packagist.org/packages/wezom-agency/browserizr)
45
[![WezomAgency](https://img.shields.io/badge/wezom-agency-red.svg)](https://github.com/WezomAgency)
56

6-
> **Browserizr** is tiny library, that detects your browser and platform,
7+
> **Browserizr** is tiny library, that detects your browser
78
> with testing `$_SERVER['HTTP_USER_AGENT']`.
89
9-
_that is PHP port of JavaScript library [WezomAgency/Browserizr](https://github.com/WezomAgency/browserizr)
10+
_that is PHP port of the JavaScript library [WezomAgency/Browserizr](https://github.com/WezomAgency/browserizr)
1011
with several limitations..._
12+
13+
---
14+
15+
## Install
16+
17+
```bash
18+
composer require wezom-agency/browserizr
19+
```
20+
21+
---
22+
23+
## API
24+
25+
### List of built-in tests
26+
27+
1. `Browserizr::$is_android`
28+
1. `Browserizr::$is_android3`
29+
1. `Browserizr::$is_android4`
30+
1. `Browserizr::$is_android5`
31+
1. `Browserizr::$is_android6`
32+
1. `Browserizr::$is_android7`
33+
1. `Browserizr::$is_android8`
34+
1. `Browserizr::$is_blackberry`
35+
1. `Browserizr::$is_blackberry10`
36+
1. `Browserizr::$is_edge`
37+
1. `Browserizr::$is_edge_android`
38+
1. `Browserizr::$is_edge_ios`
39+
1. `Browserizr::$is_ie`
40+
1. `Browserizr::$is_ie8`
41+
1. `Browserizr::$is_ie9`
42+
1. `Browserizr::$is_ie10`
43+
1. `Browserizr::$is_ie11`
44+
1. `Browserizr::$is_ipad`
45+
1. `Browserizr::$is_ipod`
46+
1. `Browserizr::$is_iphone`
47+
1. `Browserizr::$is_windows_phone`
48+
1. `Browserizr::$is_moz`
49+
1. `Browserizr::$is_opera`
50+
1. `Browserizr::$is_safari`
51+
1. `Browserizr::$is_chrome`
52+
1. `Browserizr::$is_mobile`
53+
1. `Browserizr::$is_desktop`
54+
55+
_Usage examples:_
56+
57+
```php
58+
<?php
59+
60+
use WezomAgency\Browserizr;
61+
62+
?>
63+
<?php if (Browserizr::$is_chrome) { ?>
64+
<div class="alert">Chrome is here, baby!!!</div>
65+
<?php } ?>
66+
67+
```
68+
69+
---
70+
71+
### Static methods
72+
73+
#### `add_classes($tests, $css_prefix = "")`
74+
75+
> Create string with CSS classes
76+
77+
_Parameters:_
78+
79+
Name | Data type | Default value | Description
80+
--- | --- | --- | ---
81+
`$tests` | `string[]` | | array of wanted tests
82+
`$css_prefix` | `string` | `""` | custom prefix for CSS class name
83+
84+
_Usage examples:_
85+
86+
```php
87+
<?php
88+
89+
use WezomAgency\Browserizr;
90+
91+
?>
92+
<!DOCTYPE html>
93+
<html class="<?= Browserizr::add_classes(['mobile', 'desktop']); ?>">
94+
<head>...</head>
95+
<body>...</body>
96+
</html>
97+
98+
<!-- render output -->
99+
<html class="is-mobile is-not-desktop"><!-- if mobile device -->
100+
<html class="is-not-mobile is-desktop"><!-- if desktop -->
101+
102+
```
103+
104+
```php
105+
<?php
106+
107+
use WezomAgency\Browserizr;
108+
109+
?>
110+
<!DOCTYPE html>
111+
<html class="<?= Browserizr::add_classes(['mobile', 'desktop'], 'browserizr-'); ?>">
112+
<head>...</head>
113+
<body>...</body>
114+
</html>
115+
116+
<!-- render output -->
117+
<html class="browserizr-is-mobile browserizr-is-not-desktop"><!-- if mobile device -->
118+
<html class="browserizr-is-not-mobile browserizr-is-desktop"><!-- if desktop -->
119+
120+
```
121+
122+
#### `detect($custom_user_agent = null)`
123+
124+
> re-checkout all detections
125+
126+
_Parameters:_
127+
128+
Name | Data type | Default value | Description
129+
--- | --- | --- | ---
130+
`$custom_user_agent` | `string` | `$_SERVER['HTTP_USER_AGENT']` | string for tests
131+
132+
_Usage examples:_
133+
134+
```php
135+
<?php
136+
137+
use WezomAgency\Browserizr;
138+
139+
Browserizr::detect('my_user_agent')
140+
141+
?>
142+
<?php if (Browserizr::$is_edge_ios) { ?>
143+
<div class="alert">Edge is here, baby! Yes, on iOS!</div>
144+
<?php } ?>
145+
146+
```
147+
148+
---
149+
150+

0 commit comments

Comments
 (0)