xternalsoft/laravel-patrowl 问题修复 & 功能扩展

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

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

xternalsoft/laravel-patrowl

最新稳定版本:v1.1.0

Composer 安装命令:

composer require xternalsoft/laravel-patrowl

包简介

A clean, fluent, and developer-friendly PHP wrapper for the Patrowl API

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A clean, fluent, and developer-friendly PHP wrapper for the Patrowl API. This package allows you to easily interact with assets, asset groups, and tags within the Patrowl ecosystem from your Laravel application.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

composer require xternalsoft/laravel-patrowl

You can publish and run the migrations with:

php artisan vendor:publish --tag="laravel-patrowl-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="laravel-patrowl-config"

This is the contents of the published config file:

return [
    'api_token' => env('PATROWL_API_TOKEN'),
    'base_url' => env('PATROWL_API_BASE_URL', 'https://dashboard.cloud.patrowl.io/api/auth'),
    'timeout' => 30,
    'default_organization_id' => env('PATROWL_DEFAULT_ORGANIZATION_ID'),
    'limit' => env('PATROWL_PAGINATION_LIMIT', 100),
];

Optionally, you can publish the views using

php artisan vendor:publish --tag="laravel-patrowl-views"

Usage

Configuration

Add your Patrowl API token and base URL to your .env file:

PATROWL_API_TOKEN=your-api-token
PATROWL_API_BASE_URL=https://dashboard.cloud.patrowl.io/api/auth
PATROWL_DEFAULT_ORGANIZATION_ID=1

Basic Usage

You can use the LaravelPatrowl facade to interact with the API:

use Xternalsoft\LaravelPatrowl\Facades\LaravelPatrowl;

// Get all assets
$assets = LaravelPatrowl::assets()->all();

foreach ($assets->items() as $asset) {
    echo $asset->value;
}

Managing Assets

Create an Asset

use Xternalsoft\LaravelPatrowl\Data\CreateAssetData;

$data = new CreateAssetData(
    value: 'example.com',
    description: 'My new asset',
    organization: 1
);

$asset = LaravelPatrowl::assets()->create($data);

Add a Tag to an Asset

use Xternalsoft\LaravelPatrowl\Data\AddTagToAssetData;

$data = new AddTagToAssetData(
    value: 'production',
    organization: 1
);

$response = LaravelPatrowl::assets()->addTag($assetId, $data);

if ($response->successful()) {
    // Tag added successfully
}

Remove a Tag from an Asset

$response = LaravelPatrowl::assets()->removeTag($assetId, $tagId);

Risks

List and Get Risks

// List all risks
$risks = LaravelPatrowl::risks()->all();

foreach ($risks->items() as $risk) {
    echo $risk->title . ' (' . $risk->severity->name . ')';
}

// Get a specific risk
$risk = LaravelPatrowl::risks()->get($riskId);

Export Risks to CSV

// Export all risks to CSV format
$csvContent = LaravelPatrowl::risks()->exportCsv();

file_put_contents('risks_export.csv', $csvContent);

List Risk Topics and Subtopics

// List all risk topics
$topics = LaravelPatrowl::risks()->topics();

foreach ($topics->items() as $topic) {
    echo $topic->title . ' (' . $topic->slug . ')';
}

// List all risk subtopics
$subtopics = LaravelPatrowl::risks()->subtopics();

foreach ($subtopics->items() as $subtopic) {
    echo $subtopic->title . ' (' . $subtopic->slug . ')';
}

Asset Groups

Create an Asset Group

use Xternalsoft\LaravelPatrowl\Data\CreateAssetGroupData;

$data = new CreateAssetGroupData(
    title: 'My Production Assets',
    description: 'Assets in production environment',
    organization: 1,
    assets: [123, 456] // List of asset IDs to add after creation
);

$group = LaravelPatrowl::assetGroups()->create($data);

List and Get Asset Groups

// List all asset groups
$groups = LaravelPatrowl::assetGroups()->all();

// Get a specific group
$group = LaravelPatrowl::assetGroups()->get($groupId);

Add a Tag to an Asset Group

use Xternalsoft\LaravelPatrowl\Data\AddTagToAssetData;

$data = new AddTagToAssetData(
    value: 'critical-infrastructure',
    organization: 1
);

$response = LaravelPatrowl::assetGroups()->addTag($groupId, $data);

Asset Tags

// List all available tags
$tags = LaravelPatrowl::assetTags()->all();

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固