PHP code example of forsaken-threads / get-hooked

1. Go to this page and download the library: Download forsaken-threads/get-hooked 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/ */

    

forsaken-threads / get-hooked example snippets




use ForsakenThreads\GetHooked\DeployOnPush;
use ForsakenThreads\GetHooked\WebhookHandler;

// Obviously use the path to your actual composer autoloader
b server directory.
// The second argument is a directory path to a folder that can be used to store 
// the queues.  It must be writable/readable by the web server and the queue worker.
$handler = new WebhookHandler('My GitLab Webhook Secret', '/path/to/storage');

// Register an Event Receiver with the handler.
// At a minimum you supply the repo path.  You can also supply a branch as the
// the second argument, default is `master`, or a remote as the third argument, default
// is `origin`.
$handler->addReceiver(new DeployOnPush('/path/to/repo'));

// Receive the hook from GitLab
// The handler will look for `push` events, and if it finds one, queue it up as
// a deploy command.
$handler->receiveHook();



$receiver = new DeployOnPush('/path/to/repo');
$receiver->initiatedBy('Keith Freeman')
    ->to('master')
    ->forRepo('keithfreeman/forsaken-threads-website');



use ForsakenThreads\GetHooked\QueueWorker;

// Obviously use the path to your actual composer autoloader
/readable by the web server and the queue worker.
$worker = new QueueWorker('/path/to/storage');
$worker->work();