davido/pgchecker
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
-
Sign up on the Copyleaks website.
-
Visit Copyleaks API Dashboard to generate your api keys.
-
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_emailCOPYLEAKS_KEY=your_copyleaks_api_keyCOPYLEAKS_SANDBOX=falseCOPYLEAKS_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.
davido/pgchecker 适用场景与选型建议
davido/pgchecker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 274 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 06 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 davido/pgchecker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 davido/pgchecker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 274
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-06-25