davido/pgchecker 问题修复 & 功能扩展

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

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

davido/pgchecker

最新稳定版本:v1.0.3

Composer 安装命令:

composer create-project davido/pgchecker

包简介

A package for integrating copyleaks plagiarism checker easily in your laravel application

README 文档

README

A package for integrating Copyleaks plagiarism checker easily in your Laravel app

Requirements

  • PHP 7.4 or above.
  • Laravel 8 or above.

Installation

You can install the package using composer.

composer require davido/pgchecker

You can also add the follow line to you composer.json file and save.

...
"davido/pgchecker": "dev-master"
...

Then run this command to update composer.

composer update

You need to also publish the config files

php artisan vendor:publish --provider="DavidO\PGChecker\PGCheckerServiceProvider" --tag="config"

Setup

  1. Sign up on the Copyleaks website.

  2. Visit Copyleaks API Dashboard to generate your api keys.

  3. If you previously publish the config file, you must have noticed a new file (config/copyleaks.php) you can edit the config file, or add the following to your .env file.

    COPYLEAKS_EMAIL=your_copyleaks_email

    COPYLEAKS_KEY=your_copyleaks_api_key

    COPYLEAKS_SANDBOX=false

    COPYLEAKS_WEBHOOK_BASE=ngrok_url_for_localhost_testing

Usage

You can use the following code to scan text or a file and you get a json data as a response

PGChecker::scanText("A long text to scan for plagiarism");
PGChecker::scanFile("File binary data", 'pdf');

You can use also submit text or a file for scan only without getting the result immediately.

$canId = PGChecker::submitText("A long text to scan for plagiarism");
$canId = PGChecker::submitFile("File binary data", 'pdf');

this will return a unique scan id that can be used to retrieve the result later using the following code.

PGChecker::retrieveResult($scanId)

How it works

Under the hood the package authenticate the user with copyleaks and then submits the file or text for scanning, the scanned results are receive via a webhook and the result is saved in the cache using the cache settings defined in the laravel package.

The scan results can be retrieved immediately or later with the unique scan id provided.

Local Setup and Testing

Since copyleaks uses webhook to return result, on local we will need a ngrok to retrieve the API result.

On mac use,

brew install ngrok

to install ngrok.

Then start ngrok server using,

ngrok http 8002

also start a local server on the same port using,

php artisan serve --port=8002

also update the url gotten from ngrok as the in the .env file

COPYLEAKS_WEBHOOK_BASE=https://example.com

we only need this for testing purpose and never forget to remove the variable in staging or production environment.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-06-25