Skip to content

Commit 93e8940

Browse files
committed
#4 Add simple docs that currently duplicates docs from README
1 parent 41809cb commit 93e8940

File tree

5 files changed

+69
-1
lines changed

5 files changed

+69
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Many people have contributed to project since its inception.
123123

124124
Thanks to:
125125

126-
- [Daniel Stainback](https://github.com/InteractionDesignFoundation)
126+
- [Daniel Stainback](https://github.com/Torann) (creator of the original package)
127127
- [Dwight Watson](https://github.com/dwightwatson)
128128
- [nikkiii](https://github.com/nikkiii)
129129
- [jeffhennis](https://github.com/jeffhennis)

docs/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Laravel GeoIP
2+
3+
- [Basic usage](usage.md)
4+
- [Artisan](artisan.md)
5+
- [Config](config.md)
6+
- [Services](services.md)

docs/artisan.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Artisan
2+
3+
Some services require downloading and use local database to detect Location by IP address.
4+
There is a console command to download/update database:
5+
```sh
6+
php artisan geoip:update
7+
```
8+
9+
Some cache drivers offer the ability to clear cached locations:
10+
```sh
11+
php artisan geoip:clear
12+
```

docs/services.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Services
2+
3+
## MaxMind Database
4+
5+
⚠️ Before using MaxMind driver, you must install the `geoip2/geoip2` package using the Composer package manager.
6+
7+
The database location to used is specified in the config file in the "services" section under maxmind_database.
8+
Along with the URL of where to download the database from when running the php artisan geoip:update.
9+
Note: The `geoip:update` command will need to be ran before the package will work.
10+
11+
```php
12+
'service' => 'maxmind_database',
13+
```

docs/usage.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Usage
2+
3+
There are few options to use the package:
4+
- `geoip()` helper function
5+
- `InteractionDesignFoundation\GeoIP\Facades\GeoIP` facade
6+
7+
```php
8+
geoip()->getLocation('27.974.399.65'); // Get the location from the provided IP.
9+
geoip()->getClientIP(); // Will return the user IP address.
10+
```
11+
12+
Example of Location object:
13+
```php
14+
\InteractionDesignFoundation\GeoIP\Location {
15+
[
16+
'ip' => '1.1.1.1',
17+
'iso_code' => 'US',
18+
'country' => 'United States',
19+
'city' => 'New Haven',
20+
'state' => 'CT',
21+
'state_name' => 'Connecticut',
22+
'postal_code' => '06510',
23+
'lat' => 41.28,
24+
'lon' => -72.88,
25+
'timezone' => 'America/New_York',
26+
'continent' => 'NA',
27+
'currency' => 'USD',
28+
'default' => false,
29+
]
30+
}
31+
```
32+
33+
`Location` class implements `\ArrayAccess` interface, means you can access properties of the `Location` object using array access syntax:
34+
```php
35+
$location = geoip()->getLocation();
36+
$city = $location['city'];
37+
```

0 commit comments

Comments
 (0)