承接 sarahman/laravel-http-request-api-log 相关项目开发

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

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

sarahman/laravel-http-request-api-log

Composer 安装命令:

composer require sarahman/laravel-http-request-api-log

包简介

This library stores the http request api log into a database table.

README 文档

README

Latest Version on Packagist Build Status Scrutinizer Code Quality StyleCI Total Downloads License PHP Version Require

The sarahman/laravel-http-request-api-log package provides easy to use functionality to log the http api logs in the Laravel application. All the api logs will be stored in the _api_calls table.

You can retrieve all api logs using the Sarahman\HttpRequestApiLog\Models\ApiLog model.

ApiLog::all();

Here's a more advanced example:

...
use GuzzleHttp\Psr7\Response;
use Illuminate\Database\Eloquent\Model;
use Sarahman\HttpRequestApiLog\Traits\WritesHttpLogs;

class ApiClient
{
    use WritesHttpLogs;
    ...
    ...
    public function __construct()
    {
        ...
        ...
        $this->enableLogging = false; // Overwrite the logging functionality being enabled or not.
    }
    ...
    ...
    public function sampleMethod()
    {
        ...
        ...
        $this->log('POST', $url, $options, new Response(200));
    }
}

Installation

You can install the package via composer:

composer require sarahman/laravel-http-request-api-log

Next, you need to load the service provider:

// app/config/app.php
'providers' => [
    ...
    Sarahman\HttpRequestApiLog\HttpRequestApiLogServiceProvider::class,
];

You can publish the config file with:

php artisan config:publish sarahman/laravel-http-request-api-log

This is the contents of the published config file:

return [
    /*
     * If set to false, no api log will be saved to the database.
     */
    'enabled' => true,

    /*
     * This model will be used to log activity.
     * It should extend Illuminate\Database\Eloquent\Model.
     */
    'api_log_model' => \Sarahman\HttpRequestApiLog\Models\ApiLog::class,

    /*
     * This is the database connection that will be used by the migration and
     * the ApiLog model shipped with this package. In case it's not set
     * Laravel's database.default will be used instead.
     */
    'database_connection' => 'mysql',

    /*
     * This is the name of the table that will be created by the migration and
     * used by the ApiLog model shipped with this package.
     */
    'table_name' => '_api_calls',
];

You can also publish the migration with:

php artisan migrate:publish sarahman/laravel-http-request-api-log

Now, you can create the _api_calls table by running the migrations:

php artisan migrate

N.B.: You can disable the api logging to a specific api client using the enableLogging property setting as false.

Testing

You might go to the project directory and run the following command to run test code.

composer test

Contribution

Feel free to contribute in this library. Please make your changes and send us pull requests.

Security Issues

If you discover any security related issues, please feel free to create an issue in the issue tracker or write us at aabid048@gmail.com.

License

The MIT License (MIT). Please see License File for more information.

sarahman/laravel-http-request-api-log 适用场景与选型建议

sarahman/laravel-http-request-api-log 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14.08k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 09 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「log」 「framework」 「http」 「api」 「request」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 sarahman/laravel-http-request-api-log 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 sarahman/laravel-http-request-api-log 我们能提供哪些服务?
定制开发 / 二次开发

基于 sarahman/laravel-http-request-api-log 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 14.08k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 19
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-09-01