1. Go to this page and download the library: Download 8ctopus/git-hook 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/ */
8ctopus / git-hook example snippets
use Apix\Log\Logger\File;
use HttpSoft\ServerRequest\ServerRequestCreator;
use Oct8pus\GitHubHook;
// assuming script is in DOCUMENT_ROOT/public/api/myhook/index.php
$documentRoot = __DIR__ . '/../../..';
// adjust to your flavor
'/usr/bin/git pull',
'/usr/local/bin/composer install --no-interaction --no-dev',
],
],
];
// the logger is optional but provides useful information (any PSR-3 logger will do)
// to use this logger, composer ommand failed
http_response_code($exception->getCode());
// REMOVE ME IN PRODUCTION
echo $exception->getMessage();
}
}
declare(strict_types=1);
use Apix\Log\Logger\File;
use HttpSoft\ServerRequest\ServerRequestCreator;
use Oct8pus\GiteaHook;
// assuming script is in DOCUMENT_ROOT/public/api/myhook/index.php
$documentRoot = __DIR__ . '/../../..';
],
],
];
// the logger is optional but provides useful information (any PSR-3 logger will do)
// to use this logger, composer } catch (Exception $exception) {
if ($exception->getCode() !== 0) {
// informs the webhook that the command failed
http_response_code($exception->getCode());
// REMOVE ME IN PRODUCTION
echo $exception->getMessage();
}
}