PHPackages                             marshmallow/laravel-facebook-webhook - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. marshmallow/laravel-facebook-webhook

ActiveLibrary[API Development](/categories/api)

marshmallow/laravel-facebook-webhook
====================================

A package to retrieve Facebook Leads with webhooks &amp; Graph API in Laravel.

v2.4.0(3mo ago)133.4k↓20%4MITPHPPHP ^7.4|^8.0

Since May 4Pushed 3w ago1 watchersCompare

[ Source](https://github.com/marshmallow-packages/laravel-facebook-webhook)[ Packagist](https://packagist.org/packages/marshmallow/laravel-facebook-webhook)[ Docs](https://github.com/marshmallow/laravel-facebook-webhook)[ GitHub Sponsors](https://github.com/marshmallow)[ RSS](/packages/marshmallow-laravel-facebook-webhook/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (9)Dependencies (18)Versions (15)Used By (0)

[![alt text](https://camo.githubusercontent.com/f5450f299f5713ce2f04dd5a1ba7ce9960ed4568b3574e4c4ee3cddc75477253/68747470733a2f2f6d617273686d616c6c6f772e6465762f63646e2f6d656469612f6c6f676f2d7265642d3233377834362e706e67 "marshmallow.")](https://camo.githubusercontent.com/f5450f299f5713ce2f04dd5a1ba7ce9960ed4568b3574e4c4ee3cddc75477253/68747470733a2f2f6d617273686d616c6c6f772e6465762f63646e2f6d656469612f6c6f676f2d7265642d3233377834362e706e67)

Facebook Lead Webhook for Laravel
=================================

[](#facebook-lead-webhook-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/08434242236b819f114123c9a5739161a9778cbc43cf90fd8d92e02aea3ee903/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d617273686d616c6c6f772f6c61726176656c2d66616365626f6f6b2d776562686f6f6b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marshmallow/laravel-facebook-webhook)[![Total Downloads](https://camo.githubusercontent.com/db2556df57643961dd4a41a4609433ca36ae59d0c593fad43380cedeb2c4a30e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d617273686d616c6c6f772f6c61726176656c2d66616365626f6f6b2d776562686f6f6b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marshmallow/laravel-facebook-webhook)

A package to retrieve Facebook Leads with webhooks &amp; the Graph API in Laravel.

It builds on [spatie/laravel-webhook-client](https://github.com/spatie/laravel-webhook-client) to receive and process the incoming Facebook webhook, and on [Laravel Socialite](https://socialiteproviders.com/Facebook/) for the initial Facebook authentication. On an incoming webhook, the package retrieves the lead data through the Facebook Graph API and dispatches an event on completion.

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require marshmallow/laravel-facebook-webhook
```

This package uses [spatie/laravel-webhook-client](https://github.com/spatie/laravel-webhook-client) &amp; [Laravel Socialite](https://socialiteproviders.com/Facebook/). Please read the instructions from both packages!

Publish the migration from [spatie/laravel-webhook-client](https://github.com/spatie/laravel-webhook-client) to create the table that holds the webhook calls:

```
php artisan vendor:publish --provider="Spatie\WebhookClient\WebhookClientServiceProvider" --tag="migrations"
```

Make sure to add the correct config for the Spatie webhook package:

```
'name' => 'facebook-lead',
'signing_secret' => env('FACEBOOK_CLIENT_SECRET'),
'signature_header_name' => 'X-Hub-Signature',
'signature_validator' => \Marshmallow\LaravelFacebookWebhook\SignatureValidator\FacebookSignatureValidator::class,
'process_webhook_job' => \Marshmallow\LaravelFacebookWebhook\Jobs\ProcessFacebookLeadWebhookJob::class,
```

Please see the [Socialite Base Installation Guide](https://socialiteproviders.com/usage/), then follow the provider-specific instructions below.

### Add configuration to `config/services.php`

[](#add-configuration-to-configservicesphp)

```
'facebook' => [
    'client_id' => env('FACEBOOK_CLIENT_ID'),
    'client_secret' => env('FACEBOOK_CLIENT_SECRET'),
    'redirect' => env('FACEBOOK_REDIRECT_URI'),
],
```

### Publish the package config and migration

[](#publish-the-package-config-and-migration)

Publish the config file:

```
php artisan vendor:publish --tag="laravel-facebook-webhook-config"
```

Publish and run the migration:

```
php artisan vendor:publish --tag="laravel-facebook-webhook-migrations"
php artisan migrate
```

You may also publish both at once via the service provider:

```
php artisan vendor:publish --provider="Marshmallow\LaravelFacebookWebhook\LaravelFacebookWebhookServiceProvider"
```

### Environment variables

[](#environment-variables)

Make sure the following `.env` variables are set up:

```
FACEBOOK_CALLBACK_ROUTE= # Defaults to 'webhook-client-facebook-lead'
FACEBOOK_CLIENT_ID=
FACEBOOK_CLIENT_SECRET=
FACEBOOK_PAGE_ID=
FACEBOOK_REDIRECT_URI= # e.g. '/auth/facebook'
```

Configuration
-------------

[](#configuration)

The published config file lives at `config/facebook-webhook.php`. It supports multiple webhook endpoints through the `configs` array; each entry accepts the following keys:

KeyDefaultDescription`name``facebook-lead`Name of the webhook receiving endpoint. Use `default` if you only have one.`process_facebook_webhook_job``''`Class that processes the Facebook lead data. Should extend `\Marshmallow\LaravelFacebookWebhook\Jobs\ProcessFacebookLeadJob`.`callback_route``env('FACEBOOK_CALLBACK_ROUTE', 'webhook-client-facebook-lead')`The callback route name for Facebook Leads.`graph_api_version``v14.0`The Graph API version used for Facebook requests.`app_id``env('FACEBOOK_CLIENT_ID')`The App ID from the Facebook app.`app_secret``env('FACEBOOK_CLIENT_SECRET')`The App Secret from the Facebook app.`page_id``env('FACEBOOK_PAGE_ID')`The Page ID to retrieve the leads from.Setup
-----

[](#setup)

Create a Facebook app using the [Facebook registration instructions](https://developers.facebook.com/docs/development/register). Make sure your app has the following permissions (a Page or User access token requested by a person who can advertise on the ad account and on the Page):

- The `ads_management` permission
- The `leads_retrieval` permission
- The `pages_show_list` permission
- The `pages_read_engagement` permission
- The `pages_manage_ads` permission

After setting up the migrations and the `.env`, run:

```
php artisan marshmallow:setup-facebook
```

This command guides you through authenticating with Facebook, installing the app, and installing the webhook.

Usage
-----

[](#usage)

Specify which job should process the lead data via the `process_facebook_webhook_job` key in the `config/facebook-webhook.php` config file. Your job must extend `Marshmallow\LaravelFacebookWebhook\Jobs\ProcessFacebookLeadJob`, which exposes the retrieved lead data through the `$webhookData` property (a `WebhookLeadResponse` instance).

For example, create a job:

```
use Marshmallow\LaravelFacebookWebhook\Jobs\ProcessFacebookLeadJob as MarshmallowWebhookJob;

class ProcessFacebookDataJob extends MarshmallowWebhookJob
{
    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        ray($this->webhookData);
    }
}
```

And register it in the config:

```
'process_facebook_webhook_job' => \App\Jobs\ProcessFacebookDataJob::class,
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Marshmallow](https://github.com/marshmallow-packages)
- [Spatie](https://github.com/spatie)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see the [License File](LICENSE.md) for more information.

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance89

Actively maintained with recent releases

Popularity29

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 77.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~178 days

Recently: every ~289 days

Total

11

Last Release

108d ago

Major Versions

v1.0.3 → v2.0.02022-03-02

PHP version history (2 changes)v1.0.0PHP ^7.4|^8.0

v2.0.0PHP ^7.4|^8.0|^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/be33d2624e24c516e73892b0929447cc762f3622c024ab8d0d2a59042e5d2c7f?d=identicon)[marshmallow](/maintainers/marshmallow)

---

Top Contributors

[![LTKort](https://avatars.githubusercontent.com/u/2412670?v=4)](https://github.com/LTKort "LTKort (34 commits)")[![stefvanesch](https://avatars.githubusercontent.com/u/46725619?v=4)](https://github.com/stefvanesch "stefvanesch (10 commits)")

---

Tags

laravelfacebookwebhookleadsmarshmallowlaravel-facebook-webhook

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/marshmallow-laravel-facebook-webhook/health.svg)

```
[![Health](https://phpackages.com/badges/marshmallow-laravel-facebook-webhook/health.svg)](https://phpackages.com/packages/marshmallow-laravel-facebook-webhook)
```

###  Alternatives

[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M100](/packages/dedoc-scramble)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.8k3](/packages/defstudio-telegraph)[spatie/laravel-github-webhooks

Handle GitHub webhooks in a Laravel application

94170.3k5](/packages/spatie-laravel-github-webhooks)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5022.0k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
