jruedaq/php-github-issues-report

从PHP项目仓库创建Github issue

v1.0.1 2021-03-17 23:03 UTC

This package is auto-updated.

Last update: 2024-09-18 07:20:56 UTC


README

GitHub repo size GitHub code size in bytes Packagist Downloads Packagist License Packagist Version Packagist PHP Version Support GitHub issues GitHub commit activity

PHP Github Issues Report

第一步

安装

composer require jruedaq/PHP-Github-issues-report

基本使用

创建Github个人访问令牌

在开发者设置中需要创建一个 个人访问令牌 并设置仓库权限

对于私有仓库的使用,设置所有仓库权限

Create Github token

如果只需要使用公开仓库,设置public_repo权限

Create Github token

使用库

在你的PHP文件中调用 autoload.php

require 'vendor/autoload.php';

调用函数并传递相应的参数

$issueNumber = PHPGithubIssuesReport::send($owner, $repo, $token, $title, $body);

完整示例

<?php

use jruedaq\GithubIssuesReport\PHPGithubIssuesReport;

require_once '../vendor/autoload.php';

$owner = 'Oneago';                                                          // User or company username
$repo = 'CanvasVoteSystem';                                                 // Repository name
$token = '870082df3998d104ba4164cb07217d5a734bb8fd';                        // Personal access token, get from {@link https://github.com/settings/tokens} with [repo] permission
$title = 'Testing a issue reporting from PHP';                              // Title for new issue
$body = 'This is a description text bellow title in github issues';         // Body description for new issue

try {
    $issueNumber = PHPGithubIssuesReport::send($owner, $repo, $token, $title, $body);
    echo "Created issue #$issueNumber";  // Display issue number
} catch (Exception $e) {
    echo $e->getMessage();
}