harrisonratcliffe/laravel-google-web-risk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

harrisonratcliffe/laravel-google-web-risk

Composer 安装命令:

composer require harrisonratcliffe/laravel-google-web-risk

包简介

Laravel package to allow you to easily integrate the Google Web Risk API into your application

README 文档

README

Latest Stable Version Total Downloads License

This package requires that you have a Google API key. It absolutely will not work without one.

Overview

The harrisonratcliffe/laravel-google-web-risk package provides a simple interface for integrating with the Google Web Risk API to check if URLs are harmful or not, leveraging Google's threat intelligence. This package allows developers to assess the safety of URLs based on predefined threat types, making it an essential tool for web applications that require enhanced security measures.

Right now it's only using the Search API, but I'll be updating it to include the remaining APIs later. It's free up to 100k requests per month.

This package requires that you have a Google API key. It absolutely will not work without one.

Installation

You can install the package via Composer. Run the following command in your Laravel project:

composer require harrisonratcliffe/laravel-google-web-risk

Once installed, you will need to add the service provider to your config/app.php if using Laravel versions below 5.5:

'providers' => [
    // ...
    Harrisonratcliffe\LaravelGoogleWebRisk\GoogleWebRiskServiceProvider::class,
],

Configuration

Publish the configuration file using the following Artisan command:

php artisan vendor:publish --provider="Harrisonratcliffe\LaravelGoogleWebRisk\GoogleWebRiskServiceProvider"

This will create a configuration file located at config/google-web-risk.php. You must set your Google API key in your .env file:

GOOGLE_API_KEY=your_google_api_key

You can also modify other settings, such as timeout and threat_types as needed:

'google' => [
    'api_key' => env('GOOGLE_API_KEY'),
    'timeout' => 10, // Timeout in seconds
    'threat_types' => [
        'MALWARE',
        'SOCIAL_ENGINEERING',
        'UNWANTED_SOFTWARE',
        'SOCIAL_ENGINEERING_EXTENDED_COVERAGE',
    ],
],

Important:

The Google Web Risk free tier is limited to 100,000 requests per month. Ensure to monitor your usage to avoid exceeding this limit.

Usage

Checking URL Safety

You can check the safety of a URL using the isSafe method provided by the GoogleWebRisk class:

use Harrisonratcliffe\LaravelGoogleWebRisk\GoogleWebRisk;

$url = "http://example.com";
$googleWebRisk = new GoogleWebRisk();

if ($googleWebRisk->isSafe($url)) {
    echo "The URL is safe.";
} else {
    echo "The URL may be harmful.";
}

Direct API Access

If you need to access the raw response from the Google Web Risk API to see what specific threats are flagged, you can invoke the checkUrl method directly:

$response = GoogleWebRisk::checkUrl($url);

if (isset($response['error'])) {
    // Handle error
    echo $response['details'];
} else {
    // Process response data
    var_dump($response);
}

Test URLs

Here are some handy test urls you can use while you're experimenting with the system.

License

This package is open-sourced software licensed under the GNU General Public License.

Contributing

If you would like to contribute to this project, please submit a pull request or open an issue on the GitHub repository.

harrisonratcliffe/laravel-google-web-risk 适用场景与选型建议

harrisonratcliffe/laravel-google-web-risk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 87 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 03 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 harrisonratcliffe/laravel-google-web-risk 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2025-03-25