Skip to content

Commit 5b8d535

Browse files
committed
docs: added php syntax highlighting in readme and updated contributors
1 parent 1604eae commit 5b8d535

File tree

2 files changed

+64
-39
lines changed

2 files changed

+64
-39
lines changed

Contributors.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
* https://github.com/simonschaufi
1414
* https://github.com/stayallive
1515
* https://github.com/aschempp
16+
* https://github.com/jnngr

README.md

Lines changed: 63 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,19 @@ This library can be installed via composer: `composer require visualappeal/matom
1818

1919
### Create an instance of matomo
2020

21-
require(__DIR__ . '/vendor/autoload.php');
21+
```php
22+
require(__DIR__ . '/vendor/autoload.php');
2223

23-
use VisualAppeal\Matomo;
24+
use VisualAppeal\Matomo;
2425

25-
$matomo = new Matomo('http://stats.example.org', 'my_access_token', 'siteId');
26+
$matomo = new Matomo('http://stats.example.org', 'my_access_token', 'siteId');
27+
```
2628

2729
There are some basic parameters (period, date, range) which you can define at the beginning. They do not change until you reset them with
2830

29-
$matomo->reset();
31+
```php
32+
$matomo->reset();
33+
```
3034

3135
So you can execute multiple requests without specifying the parameters again.
3236

@@ -38,48 +42,62 @@ The ID of your website, single number, list separated through comma `"1,4,7"`, o
3842

3943
The period you request the statistics for
4044

41-
Matomo::PERIOD_DAY
42-
Matomo::PERIOD_WEEK
43-
Matomo::PERIOD_MONTH
44-
Matomo::PERIOD_YEAR
45-
Matomo::PERIOD_RANGE
45+
```php
46+
Matomo::PERIOD_DAY
47+
Matomo::PERIOD_WEEK
48+
Matomo::PERIOD_MONTH
49+
Matomo::PERIOD_YEAR
50+
Matomo::PERIOD_RANGE
51+
```
4652

4753
If you set the period to `Matomo::PERIOD_RANGE` you can specify the range via
4854

49-
$matomo->setRange('2012-01-14', '2012-04-30'); //All data from the first to the last date
50-
$matomo->setRange('2012-01-14', Matomo::DATE_YESTERDAY); //All data from the first date until yesterday
51-
$matomo->setRange('2012-01-14'); //All data from the first date until now
55+
```php
56+
$matomo->setRange('2012-01-14', '2012-04-30'); //All data from the first to the last date
57+
$matomo->setRange('2012-01-14', Matomo::DATE_YESTERDAY); //All data from the first date until yesterday
58+
$matomo->setRange('2012-01-14'); //All data from the first date until now
59+
```
5260

5361
If you set it to something other than `Matomo::PERIOD_RANGE` you can specify the date via:
5462

55-
$matomo->setPeriod(x);
56-
$matomo->setDate('2012-03-03');
63+
```php
64+
$matomo->setPeriod(x);
65+
$matomo->setDate('2012-03-03');
5766

58-
Case x of PERIOD_DAY the report is created for the third of march, 2012
59-
Case x of PERIOD_WEEK the report is created for the first week of march, 2012
60-
Case x of PERIOD_MONTH the report is created for march, 2012
61-
Case x of PERIOD_YEAR the report is created for 2012
67+
Case x of PERIOD_DAY the report is created for the third of march, 2012
68+
Case x of PERIOD_WEEK the report is created for the first week of march, 2012
69+
Case x of PERIOD_MONTH the report is created for march, 2012
70+
Case x of PERIOD_YEAR the report is created for 2012
71+
```
6272

6373
### date
6474

6575
Set the date via
6676

67-
$matomo->setDate('YYYY-mm-dd');
77+
```php
78+
$matomo->setDate('YYYY-mm-dd');
79+
```
6880

6981
Or use the constants
7082

71-
$matomo->setDate(Matomo::DATE_TODAY);
72-
$matomo->setDate(Matomo::DATE_YESTERDAY);
83+
```php
84+
$matomo->setDate(Matomo::DATE_TODAY);
85+
$matomo->setDate(Matomo::DATE_YESTERDAY);
86+
```
7387

7488
Report for the last seven weeks including the current week
7589

76-
$matomo->setPeriod(Matomo::PERIOD_WEEK);
77-
$matomo->setDate('last7');
90+
```php
91+
$matomo->setPeriod(Matomo::PERIOD_WEEK);
92+
$matomo->setDate('last7');
93+
```
7894

7995
Report for the last 2 years without the current year
8096

81-
$matomo->setPeriod(Matomo::PERIOD_YEAR);
82-
$matomo->setDate('previous2');
97+
```
98+
$matomo->setPeriod(Matomo::PERIOD_YEAR);
99+
$matomo->setDate('previous2');
100+
```
83101

84102
### segment, idSubtable, expanded
85103

@@ -89,32 +107,38 @@ For some functions you can specify `segment`, `idSubtable` and `expanded`. Pleas
89107

90108
Specify a output format via
91109

92-
$matomo->setFormat(Matomo::FORMAT_JSON);
110+
```php
111+
$matomo->setFormat(Matomo::FORMAT_JSON);
112+
```
93113

94114
JSON is converted with `json_decode` before returning the request.
95115

96116
All available formats
97117

98-
Matomo::FORMAT_XML
99-
Matomo::FORMAT_JSON
100-
Matomo::FORMAT_CSV
101-
Matomo::FORMAT_TSV
102-
Matomo::FORMAT_HTML
103-
Matomo::FORMAT_RSS
104-
Matomo::FORMAT_PHP
118+
```php
119+
Matomo::FORMAT_XML
120+
Matomo::FORMAT_JSON
121+
Matomo::FORMAT_CSV
122+
Matomo::FORMAT_TSV
123+
Matomo::FORMAT_HTML
124+
Matomo::FORMAT_RSS
125+
Matomo::FORMAT_PHP
126+
```
105127

106128

107129
## Example
108130

109131
Get all the unique visitors from yesterday:
110132

111-
require(__DIR__ . '/vendor/autoload.php');
133+
```php
134+
require(__DIR__ . '/vendor/autoload.php');
112135

113-
use VisualAppeal\Matomo;
136+
use VisualAppeal\Matomo;
114137

115-
$matomo = new Matomo('http://stats.example.org', 'my_access_token', 1, Matomo::FORMAT_JSON);
138+
$matomo = new Matomo('http://stats.example.org', 'my_access_token', 1, Matomo::FORMAT_JSON);
116139

117-
$matomo->setPeriod(Matomo::PERIOD_DAY);
118-
$matomo->setDate(Matomo::DATE_YESTERDAY);
140+
$matomo->setPeriod(Matomo::PERIOD_DAY);
141+
$matomo->setDate(Matomo::DATE_YESTERDAY);
119142

120-
echo 'Unique visitors yesterday: ' . $matomo->getUniqueVisitors();
143+
echo 'Unique visitors yesterday: ' . $matomo->getUniqueVisitors();
144+
```

0 commit comments

Comments
 (0)