1
1
# Tatter\Visits
2
2
Lightweight traffic tracking for CodeIgniter 4
3
3
4
- [ ![ ] ( https://github.com/tattersoftware/codeigniter4-visits/workflows/PHPUnit/badge.svg )] ( https://github.com/tattersoftware/codeigniter4-visits/actions?query=workflow%3A%22PHPUnit )
5
- [ ![ ] ( https://github.com/tattersoftware/codeigniter4-visits/workflows/PHPStan/badge.svg )] ( https://github.com/tattersoftware/codeigniter4-visits/actions?query=workflow%3A%22PHPStan )
4
+ [ ![ ] ( https://github.com/tattersoftware/codeigniter4-visits/workflows/PHPUnit/badge.svg )] ( https://github.com/tattersoftware/codeigniter4-visits/actions/workflows/phpunit.yml )
5
+ [ ![ ] ( https://github.com/tattersoftware/codeigniter4-visits/workflows/PHPStan/badge.svg )] ( https://github.com/tattersoftware/codeigniter4-visits/actions/workflows/phpstan.yml )
6
+ [ ![ ] ( https://github.com/tattersoftware/codeigniter4-visits/workflows/Deptrac/badge.svg )] ( https://github.com/tattersoftware/codeigniter4-visits/actions/workflows/deptrac.yml )
6
7
[ ![ Coverage Status] ( https://coveralls.io/repos/github/tattersoftware/codeigniter4-visits/badge.svg?branch=develop )] ( https://coveralls.io/github/tattersoftware/codeigniter4-visits?branch=develop )
7
8
8
9
## Quick Start
@@ -19,28 +20,47 @@ Provides automated traffic tracking for CodeIgniter 4
19
20
20
21
Install easily via Composer to take advantage of CodeIgniter 4's autoloading capabilities
21
22
and always be up-to-date:
22
- * ` > composer require tatter/visits `
23
+ ``` shell
24
+ > composer require tatter/visits
25
+ ```
23
26
24
27
Or, install manually by downloading the source files and adding the directory to
25
- ` app/Config/Autoload.php ` .
28
+ ** app/Config/Autoload.php** .
26
29
27
30
Once the files are downloaded and included in the autoload, run any library migrations
28
31
to ensure the database is setup correctly:
29
- * ` > php spark migrate -all `
32
+ ``` shell
33
+ > php spark migrate --all
34
+ ```
30
35
31
36
## Configuration (optional)
32
37
33
38
The library's default behavior can be altered by extending its config file. Copy
34
39
** examples/Visits.php** to ** app/Config/** and follow the instructions in the
35
- comments. If no config file is found in app/Config the library will use its own.
40
+ comments. If no config file is found in ** app/Config/ ** the library will use its own.
36
41
37
42
## Usage
38
43
39
44
If installed correctly CodeIgniter 4 will detect and autoload the class, service, and
40
45
config. The library includes an event listening for ` post_controller_constructor ` to
41
46
record page loads. If you prefer to handle them manually you may use the service to load
42
47
the class and record the current visit:
43
- * ` service('visits')->record(); `
48
+ ``` php
49
+ service('visits')->record();
50
+ ```
51
+
52
+ When manually tracking be sure to disable automated tracking in your Config file:
53
+ ``` php
54
+ class Visits extends BaseConfig
55
+ {
56
+ /**
57
+ * Whether to enable tracking in all controllers using
58
+ * the post_controller_constructor event.
59
+ */
60
+ public bool $trackAllPages = true;
61
+ ```
62
+
63
+ You may also limit which routes are tracked by adding them to the ` $excludeUris ` property.
44
64
45
65
## Accessing data
46
66
0 commit comments