https://github.com/trylife/yii2-ip-access
YII2 IP访问权限
https://github.com/trylife/yii2-ip-access
Last synced: 4 months ago
JSON representation
YII2 IP访问权限
- Host: GitHub
- URL: https://github.com/trylife/yii2-ip-access
- Owner: trylife
- Created: 2017-03-17T12:39:54.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-12-09T03:44:52.000Z (over 6 years ago)
- Last Synced: 2025-10-07T07:47:07.559Z (8 months ago)
- Language: PHP
- Size: 6.84 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# yii2-ip-access IP访问限制
## Installation
```
composer require trylife/yii2-ip-access
```
## Configure
### 迁移数据
```
./yii migrate --migrationPath=@vendor/trylife/yii2-ip-access/migrations
```
### 配置模块
```
'modules' => [
...
'ip-access' => [
'class' => 'trylife\ipAccess\Module',
'controllerMap' => [
'ping' => [
'class' => 'trylife\ipAccess\controllers\PingController',
'accessKey' => 'jGajhDpsy2kKqDslFNcFt0zNF17BYqnT',
],
],
],
...
],
```
### crontab 定时访问
```
curl yourDomain/ip-access/ping/ping?accessKey=jGajhDpsy2kKqDslFNcFt0zNF17BYqnT
```
### 白名单访问控制
```
'as IpWhiteListBehavior' => [
'class' => 'trylife\ipAccess\behaviors\IpWhiteListBehavior',
'open' => true,
'allowIps' => [
'127.0.0.1',
],
'allowRoutes' => [
'ip-access/ping/ping'
],
],
```