PHP code example of love-oss / github-event-parser

1. Go to this page and download the library: Download love-oss/github-event-parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

love-oss / github-event-parser example snippets




use LoveOSS\Github\Exception\InvalidPhpConfigurationException;

try {
    $commits = $pullRequest->getCommits(); // use the GitHub API when called.
} catch(InvalidPhpConfigurationException $exception) {
    // ...
}


oveOSS\Github\Parser\WebhookResolver;

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
     $decodedJson = json_decode(file_get_contents('php://input'), true);
     $resolver    = new WebhookResolver();
     $event       = $resolver->resolve($decodedJson); // ex: an instance of `IssueCommentEvent`
     echo($event::name()); // IssueCommentEvent

     /* ... do your own business */
}


$issueCommentEvent->issue;    // instance of LoveOSS/Entity/Issue
$issueCommentEvent->user;     // instance of LoveOSS/Entity/User
$issueCommentEvent->comment;  // instance of LoveOSS/Entity/Comment


$issuesEvent->action;      // Can be one of "assigned", "unassigned", "labeled", "unlabeled", "opened", "closed", or "reopened".
$issuesEvent->assignee;    // optional: the assignee of the issue(LoveOSS/Entity/User)
$issuesEvent->issue;       // instance of LoveOSS/Entity/Issue
$issuesEvent->label;       // optional: the label of the issue(LoveOSS/Entity/Label)
$issuesEvent->repository;  // instance of LoveOSS/Entity/Repository
$issuesEvent->sender;      // instance of LoveOSS/Entity/User


$forkEvent->forkedRepository;  // instance of LoveOSS/Entity/Repository
$forkEvent->owner;             // instance of LoveOSS/Entity/User
$forkEvent->repository;        // instance of LoveOSS/Entity/Repository
$forkEvent->forker;            // instance of LoveOSS/Entity/User


$deploymentStatusEvent->deployment;   // instance of LoveOSS/Entity/Deployment
$deploymentStatusEvent->sender;       // instance of LoveOSS/Entity/User
$deploymentStatusEvent->repository;   // instance of LoveOSS/Entity/Repository

$pullRequestEvent->pullRequest;   // instance of LoveOSS/Entity/PullRequest
$pullRequest->action;
/**
 * Can be one of “assigned”, “unassigned”, “labeled”, “unlabeled”, “opened”, “closed”, or “reopened”, or “synchronize”.
 * If the action is “closed” and the merged key is false, the pull request was closed with unmerged commits.
 * If the action is “closed” and the merged key is true, the pull request was merged.
 */
$pullRequest->number;             // the pull request number
$pullRequest->repository;         // instance of LoveOSS/Entity/Repository

$pushEvent->ref       // the full Git ref that was pushed ex: refs/heads/master
$pushEvent->head      // the SHA of the most recent commit on ref after the push
$pushEvent->before    // the SHA of the most recent commit on ref before the push
$pushEvent->size      // the number of commits in the push
$pushEvent->commits   // an array of objects that describe the pushed commits 


$statusEvent->sha;           // something like "9049f1265b7d61be4a8904a9a27120d2064dab3b"
$statusEvent->status;        // Can be one of "success", "failure" or "error".
$statusEvent->commiter;      // instance of LoveOSS/Entity/User
$statusEvent->repository;    // instance of LoveOSS/Entity/Repository


$watchEvent->action;        // "started"
$watchEvent->user           // instance of LoveOSS\Entity\User
$watchEvent->repository     // instance of LoveOSS\Entity\Repository


$pullRequestReviewCommentEvent->action          // "created"
$pullRequestReviewCommentEvent->comment         // instance of LoveOSS\Entity\Comment
$pullRequestReviewCommentEvent->pullRequest     // instance of LoveOSS\Entity\PullRequest
$pullRequestReviewCommentEvent->repository      // instance of LoveOSS\Entity\Repository
$pullRequestReviewCommentEvent->sender          // instance of LoveOSS\Entity\User


$gollumEvent->pages          // an array of LoveOSS\Entity\Page objects
$gollumEvent->repository     // instance of LoveOSS\Entity\Repository
$gollumEvent->sender         // instance of LoveOSS\Entity\User