Download the PHP package craftcms/webhooks without Composer

On this page you can find all versions of the php package craftcms/webhooks. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package webhooks

Webhooks for Craft CMS

This plugin adds the ability to manage “webhooks” in Craft CMS, which will send GET or POST requests when certain events occur.

It can be used to integrate your Craft project with task automation tools like Zapier or Netlify build hooks.

Requirements

This plugin requires Craft CMS 4.0.0+ or 5.0.0+.

Installation

You can install this plugin from the Plugin Store or with Composer.

From the Plugin Store

Go to the Plugin Store in your project’s Control Panel and search for “Webhooks”. Then press Install in its modal window.

With Composer

Open your terminal and run the following commands:

Configuration

To configure Webhooks, go to SettingsWebhooks, or create a config/webhooks.php file, which returns an array.

The array can define the following keys:

Managing Webhooks

To manage your webhooks, go to Settings → Webhooks in your project’s Control Panel.

Webhook Groups

Webhooks can optionally be organized into groups. You can create a new group by clicking the “New group” button in the sidebar.

If a group is deleted, any webhooks in it will become ungrouped. (They will not be deleted along with the group.)

Creating Webhooks

To create a new webhook, click the “New webhook” button.

Webhooks listen to events triggered by system classes. So you must determine the name of the class that will be triggering the event (the “Sender Class”), as well as the event name (either an EVENT_* constant name, or its value).

The Sender Class can be a subclass of the class that triggers the event. For example, all elements fire an afterSave event after they’ve been saved, courtesy of their base class, craft\base\Element. However if you’re only interested in sending a webhook when an entry gets saved, you can set the Sender Class to craft\elements\Entry.

Webhook URLs can be set to an environment variable ($VARIABLE_NAME) or Twig code. If you set it to Twig code, you can reference the triggered event via an event variable.

See Integrating with Task Automation Tools for examples on how to get a Webhook URL from various task automation tools.

Webhooks can either send a GET request, or a POST request with a JSON body containing the following keys:

Filtering Events

Some events can have filters applied to them, which prevent webhooks from being executed under certain conditions.

Ignored filters () will not have any impact. Positive filters () will be required for a webhook to execute, and a negative filter (×) will prevent it.

Only element class events and certain craft\services\Elements events have any filters out of the box, but modules and plugins can register additional filters using the craft\webhooks\Plugin::EVENT_REGISTER_FILTER_TYPES event.

Filter type classes must implement craft\webhooks\filters\FilterInterface:

Debouncing Webhooks

You can prevent multiple similar webhooks from being sent by setting a “Debounce Key Format” on your webhook. This is a Twig template that defines a “debounce key” for the webhook. If two webhooks generate the same debounce key, only the second one will actually be sent.

An event variable will be available to it that references the event that was triggered.

For example, if your webhook is for an entry (craft\elements\Entry), then you could set the Debounce Key Format to {{ event.sender.id }} to prevent multiple webhook requests from being queued up at the same time.

Sending Custom Headers

You can send custom headers along with webhook requests using the Custom Headers setting.

Header values can be set to an environment variable using the $VARIABLE_NAME syntax, or a Twig template.

An event variable will be available to the Twig template, set to the event that triggered the webhook.

You can have multiple headers that have the same name, and if a header value takes up multiple lines (after any empty lines have been discarded), each line will be sent as its own header, all using the same header name.

Sending More Data

If you need more data than what’s in the default POST request payload, you can fill in the “Extra User Attributes”, “Extra Sender Attributes”, and “Extra Event Attributes” fields.

The attributes listed here (separated by newlines) will be passed to the $extraFields argument of the user/sender/event-property’s [toArray()](https://www.yiiframework.com/doc/api/2.0/yii-base-arrayabletrait#toArray()-detail) method (if it has one).

For “Extra Event Attributes”, each attribute should be prefixed with the name of the property and a dot (e.g. element.author will include the author attribute of an $element property).

Sending Custom Payloads

You can completely customize the webhook payload by ticking the “Send a custom payload” checkbox. That will reveal the “Payload Template” field, where you can enter the desired body contents.

That field supports Twig, so you can make this dynamic. An event variable will be available to it that references the event that was triggered.

If the output is valid JSON, then webhook requests will be sent with an application/json content type.

Toggling Webhooks

Webhooks can be enabled or disabled from both the Webhooks index page and within their Edit Webhook pages.

Only enabled webhooks will send webhook requests when their corresponding events are triggered.

You can disable all webhooks by setting disableAllWebhooks to true in your config/webhooks.php file.

Integrating with Task Automation Tools

Netlify

To trigger a Netlify build using Webhooks, follow these steps:

  1. Within your Netlify dashboard, go to SettingsBuild & deployContinuous deploymentBuild hooks.
  2. Select Add build hook.
  3. Fill out the build hook settings and save it.
  4. Copy the build hook URL.
  5. Within your Craft control panel, go to WebhooksNew webhook.
  6. Paste the build hook URL into the Webhook URL field, fill out the remaining settings, and save the webhook.

Zapier

To integrate Webhooks with Zapier, follow these steps:

  1. Within your Zapier dashboard, click Make a Zap!.
  2. Select Webhooks under Built-in Apps.
  3. Select Catch Hook and click Save + Continue.
  4. Click Continue without entering anything in the Pick off a Child Key field.
  5. Copy the webhook URL.
  6. Within your Craft control panel, go to to WebhooksNew webhook.
  7. Paste the webhook URL into the Webhook URL field, fill out the remaining settings, and save the webhook.
  8. Perform an action in Craft that will trigger your webhook.
  9. Back in Zapier, click the Ok, I did this button.
  10. Ensure that Zapier pulled in the webhook, and click Continue.
  11. Finish setting up the zap and make sure it’s enabled.

IFTTT

To integrate Webhooks with IFTTT, follow these steps:

  1. Within your My Applets page in IFTTT, click New Applet.
  2. Click on +this.
  3. Search for “webhooks” and select Webhooks below.
  4. Click Connect.
  5. Click on the Receive a web request box.
  6. Give your trigger an event name based on your Craft webhook name, but in snake_case.
  7. Finish setting up the applet.
  8. Go to your Webhooks page on IFTTT, and click the Documentation link.
  9. Type the event name you entered in step 6 into the {event} text box.
  10. Copy the URL beginning with https://maker.ifttt.com/trigger/.
  11. Within your Craft control panel, go to to WebhooksNew webhook.
  12. Paste the webhook URL into the Webhook URL field, fill out the remaining settings, and save the webhook.

Note: Unfortunately IFTTT’s webhooks API is pretty limited, so no webhook data will be available to your applet action.


All versions of webhooks with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0.2
craftcms/cms Version ^4.0.0-RC2|^5.0.0-beta.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package craftcms/webhooks contains the following files

Loading the files please wait ....