PHP Classes

File: src/Public/index.php

Recommend this page to a friend!
  Classes of Matheusz Maydana   Webhook Deploy   src/Public/index.php   Download  
File: src/Public/index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Webhook Deploy
Webhook handler to update projects from GitHub
Author: By
Last change:
Date: 18 days ago
Size: 906 bytes
 

Contents

Class file image Download
<?php

declare(strict_types=1);

namespace
App\Public;

$pathVendor = __DIR__.'/../../vendor/autoload.php';
$pathLoader = __DIR__.'/../Utils/loader.php';
if(!
file_exists($pathLoader)){
    die(
'Loader não encontrado.');
}
require_once
$pathLoader;

if (!
file_exists($pathVendor)) {
    die(
'Execute o comando: composer install');
}

require_once
$pathVendor;

use
App\GitHub\GitHubHandler;
use
App\Utils\Env;
use
App\Utils\Logger;
use
Exception;

$env = new Env();
$logger = new Logger();

try {

   
$githubHandler = new GithubHandler(
       
env: $env,
       
logger: $logger,
       
headers: $_SERVER,
       
dataPost: file_get_contents('php://input')
    );

   
$githubHandler->execute();

    echo
$githubHandler->response;
    exit;

}catch (
Exception $erro){

   
$logger->log($erro->getMessage());

   
header('HTTP/1.1 500 Internal Server Error');
    echo
$erro->getMessage();
    exit;
}