Skip to content

joesama/webhook

Repository files navigation

WebHook

HTTP Request Wrapper

Webhook Installation Validation Scrutinizer Code Quality Code Coverage Build PHPStan

Installation

Simple installation via composer :

composer require "joesama/webhook"

Usage/Examples

Define connector

If in need of pre-configured connector, a connector class can be created by extending Joesama\Webhook\Connectors\AbstractConnector class and implement Joesama\Webhook\Connectors\ConnectorContract interface.

    class ExamplesConnector extends AbstractConnector implements ConnectorContract
    {
        /**
         * Define configuration parameter to be attach to request.
         */
        public function webHookConfiguration(): array
        {
            return [];
        }
    
        /**
         * Define request content to be send.
         */
        public function webHookContent(): array
        {
            return [];
        }
    
        /**
         * Define request header to attach to request.
         */
        public function webHookHeader(): array
        {
            return [];
        }
    }

Initiate Request

To initiate a request can be simply by calling Joesama\Webhook\Web\Hook class and called the getResponse method.

    $hook = new Hook();
    
    $hook->setRequestBody([]);
    
    $hook->getResponse('http://www.google.com', 'GET');

To use pre-configured connector, pass it as parameter to the Hook class

    $connector = new ExamplesConnector();

    $hook = new Hook($connector);

License

joesama/webhook is open-sourced software licensed under the MIT license.

About

HTTP Request Wrapper

Topics

Resources

License

Stars

1 star

Watchers

2 watching

Forks

Packages

 
 
 

Contributors

Languages