PHPackages                             denobraz/laravel-contact-form - 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. denobraz/laravel-contact-form

ActiveLibrary[API Development](/categories/api)

denobraz/laravel-contact-form
=============================

1.0.2(1y ago)5286MITPHPPHP ^8.1

Since Sep 1Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Denobraz/laravel-contact-form)[ Packagist](https://packagist.org/packages/denobraz/laravel-contact-form)[ RSS](/packages/denobraz-laravel-contact-form/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (3)DependenciesVersions (3)Used By (0)

This small laravel package helps you quickly connect the contact form api for your site by simply defining the types and fields in the configuration file.

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

[](#installation)

To install the package, run the command:

```
composer require denobraz/laravel-contact-form
```

After installation, you need to publish the configuration file:

```
php artisan vendor:publish --provider="Denobraz\LaravelContactForm\ContactFormServiceProvider" --tag="config"
```

After that, you can configure the contact form in the file `config/contact_form.php`.

To publish the migration file, run the command:

```
php artisan vendor:publish --provider="Denobraz\LaravelContactForm\ContactFormServiceProvider" --tag="migrations"
```

After that, you can run the migration:

```
php artisan migrate
```

Usage
-----

[](#usage)

### Registering the routes

[](#registering-the-routes)

To use contact form add the following code to your api routes:

```
Route::post('/contact-form', Denobraz\LaravelContactForm\Http\Controllers\ContactFormController::class);
```

### Define contact form types

[](#define-contact-form-types)

Default configuration file include `default` contact form type with `name`, `email`, `phone`, `message` fields.

```
'types' => [
        // `default` is the name of the contact form type
        'default' => [
            'data' => [
                // Here is rules for validation
                'name' => 'string|required',
                'email' => 'string|required|email',
                'phone' => 'string|nullable',
                'message' => 'string|nullable',
            ],
            'messages' => [
                // If you want to override the default message for some field
                // You can leave this array empty
                'name.required' => 'Name is required',
            ],
            'attributes' => [
                // If you want to override the default attribute name for some field
                // You can leave this array empty
                'name' => 'Name',
            ],
            'callbacks' => [
                // Here is the list of callbacks that will be called after the form is validated
                // You can leave this array empty (maybe just for record form data in the database)
                Denobraz\LaravelContactForm\Callbacks\DummyContactFormCallback::class,
            ]
        ],
        // `newsletter` is the name of the contact form type
        'newsletter' => [
            'data' => [
                'email' => 'string|required|email',
            ],
        ]
    ]
```

You can attach callbacks to any type of contact form (notification to the administrator, response to the client, sending an application to the CRM, etc...).

Any callback is Job-like class that extends `Denobraz\LaravelContactForm\Callbacks\ContactFormCallback`.

If you want to create queueable callback, you can extend `Denobraz\LaravelContactForm\Callbacks\QueueableContactFormCallback` class.

Also, configuration allows you: (Don't forget to notify the users about sensitive data processing)

- `save_contact_forms` - if you want to store the form data in the database
- `save_cookies` - if you want to store the user's cookies
- `save_ip` - if you want to store the user's ip
- `save_user_agent` - if you want to store the user's user-agent
- `save_referrer` - if you want to store the user's referrer
- `save_user_id` - if you want to store the user's id

Examples
--------

[](#examples)

Here is example of callback that sends email to the administrator:

```
namespace App\ContactForm\Callbacks;

use App\Notifications\ManagerContactFormNotification;
use Denobraz\LaravelContactForm\Callbacks\ContactFormCallback;
use Illuminate\Support\Facades\Notification;

class SendManagerEmail extends ContactFormCallback
{
    // You must implement the `handle` method
    // where you can process the contact form data
    public function handle(): void
    {
        // You can access the contact form data using the following methods:
        $email = $this->contactForm->data('email');

        // To use the cookies, and meta-data, you need allow storing them in the config file.
        $fbpCookie = $this->contactForm->cookie('fbp');
        $ip = $this->contactForm->ip();
        $userAgent = $this->contactForm->userAgent();
        $referer = $this->contactForm->referer();
        $userId = $this->contactForm->userId();
        $someOtherMeta = $this->contactForm->meta('some_other_meta');

        // In the notification class we pass the contact form model with data
        $notification = new ManagerContactFormNotification($this->contactForm);
        Notification::route('mail', 'admin@test.com')->notify($notification);
    }
}
```

Request to `/api/contact-form`:

```
{
  "type": "default",
  "data": {
    "name": "John Doe",
    "email": "example@test.com",
    "phone": "+1234567890",
    "message": "Hello, world!"
  }
}
```

Error response:

```
{
    "message": "Name is required (and 1 more error)",
    "errors": {
        "data.name": [
            "Name is required"
        ],
        "data.email": [
            "The Email field is required."
        ]
    }
}
```

Success response:

```
{
    "success": true
}
```

You can see frontend code example in the `demo` directory.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance40

Moderate activity, may be stable

Popularity16

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

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 ~156 days

Total

2

Last Release

506d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5bd9fa93f42991ad7de884c05ece762db951db576db02e2fb751a880970beb4c?d=identicon)[Denobraz](/maintainers/Denobraz)

---

Tags

apicontact-formsformslaravelnewsletter

### Embed Badge

![Health badge](/badges/denobraz-laravel-contact-form/health.svg)

```
[![Health](https://phpackages.com/badges/denobraz-laravel-contact-form/health.svg)](https://phpackages.com/packages/denobraz-laravel-contact-form)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35816.3M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172437.8k11](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93452.6k6](/packages/botman-driver-telegram)[pixelant/pxa-social-feed

Add Facebook, Instagram, and Twitter feeds to your site.

2349.3k](/packages/pixelant-pxa-social-feed)

PHPackages © 2026

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