承接 amir-hossein5/laravel-ip-logger 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

amir-hossein5/laravel-ip-logger

Composer 安装命令:

composer require amir-hossein5/laravel-ip-logger

包简介

README 文档

README

Mixes getting details of ip and saving it.

Prerequisites

  • Laravel ^8.0|^9.0
  • PHP 8
  • guzzlehttp/guzzle: ^6.3.1|^7.0.1

Installation

composer require amir-hossein5/laravel-ip-logger

and for publishing configuration file:

php artisan vendor:publish --tag ipLogger

Usage

For just getting details:

use AmirHossein5\LaravelIpLogger\Facades\IpLogger;

IpLogger::getDetails();

Methods for work with details:

method description
detailsBe() Writing details manually.
prepare() Editting predefined details.

for Example:

use AmirHossein5\LaravelIpLogger\Facades\IpLogger;

IpLogger::prepare(function ($details) {
  return $details + ['test' => 'test'];
})->getDetails();

Saving to database

use AmirHossein5\LaravelIpLogger\Facades\IpLogger;

IpLogger::model(ModelName::class)
  ->updateOrCreate(
    fn ($details) => [
      'ip'        => $details['query']
    ],
    fn ($details) => [
      'continent' =>  $details['continent'],
      'country'   =>  $details['country'],
      ...
    ],
);

For saving there are two methods, create, updateOrCreate, and work like laravel ones.

Manually getting details

By default has been wroten two apis to getting details of ip, ip_api ,and vpn_api. It's settable in config file.

Or if you want to use another api get details manually.

use \AmirHossein5\LaravelIpLogger\Facades\IpLogger;

IpLogger::detailsBe(function () {
  return [ ... ];
})->updateOrCreate(...);

Exception Handling

Except exceptions that when saving to database(e.g, create, updateOrCreate) happens, can be handle by using:

Getting Last Exception That Happened

use AmirHossein5\LaravelIpLogger\Facades\IpLogger;

IpLogger::getLastException();

Catching Exceptions Inline

use AmirHossein5\LaravelIpLogger\Facades\IpLogger;

IpLogger::catch(function ($exception) {
  // send mail ...
})...;

You should use this as the first method.

When using this way no event will be dispatch.

Listening For Exceptions

/**
 * The event listener mappings for the application.
 *
 * @var array
 */
protected $listen = [
  AmirHossein5\LaravelIpLogger\Events\Failed::class => [
    IpLoggerFailed::class,
  ]
];

License

License

统计信息

  • 总下载量: 8
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-02-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固