coder-manjeet/laravel-contact-form
Composer 安装命令:
composer require coder-manjeet/laravel-contact-form
包简介
A simple and customizable Laravel package to handle contact forms. This package allows you to easily manage contact form submissions, send emails, and store inquiries in the database.
README 文档
README
A simple and customizable Laravel package to handle contact forms. This package allows you to easily manage contact form submissions, send emails, and store inquiries in the database.
Table of Contents
Installation
You can install the package via Composer. Run the following command in your terminal:
composer require coder-manjeet/laravel-contact-form
After installing the package, you need to publish the configuration file and run the migration to create the necessary database table.
Publish Configuration
To publish the configuration file, run the following Artisan command:
php artisan vendor:publish --provider="CoderManjeet\\LaravelContactForm\\ContactFormServiceProvider" --tag="contact-form-config"
This will create a contact-form.php file in your config directory, where you can customize the package settings.
Run Migrations
Next, run the migration to create the contacts table in your database:
php artisan migrate
This will create the table where contact form submissions will be stored.
Add Service Provider (Optional for Laravel 5.5+)
If you are using Laravel 5.5 or above, the package will automatically register the service provider. For older versions, you need to manually add the service provider in your config/app.php file
'providers' => [ // Other service providers... CoderManjeet\LaravelContactForm\ContactFormServiceProvider::class, ],
Add Routes
Finally, ensure that the package routes are loaded by adding the following line to your routes/web.php file:
CoderManjeet\LaravelContactForm\ContactFormServiceProvider::routes();
This will register the necessary routes for the contact form.
Configuration
After publishing the configuration file, you can customize the package settings by editing the config/contact-form.php file. This file contains various options such as email settings, form fields, and validation rules.
Example Configuration
Here is an example of how you might configure the config/contact-form.php file:
return [ 'emails' => [ 'admin_email' => env('CONTACT_FORM_ADMIN_EMAIL', 'test@example.com'), 'disable_admin_mail' => env('CONTACT_FORM_DISABLE_ADMIN_EMAIL', false), 'disable_user_mail' => env('CONTACT_FORM_DISABLE_USER_EMAIL', false), 'disable_mail_queue' => env('CONTACT_FORM_EMAIL_QUEUEUE', false) ], 'validation_rules' => [ 'name' => 'required|string|max:255', 'email' => 'required|email|max:255', 'subject' => 'required|string|max:255', 'message' => 'required|string|max:1000', ] ];
Customization
Views
The package includes default Blade views for the contact form and email templates. You can customize these views by publishing them to your application's resources/views/vendor/contact-form directory:
php artisan vendor:publish --provider="CoderManjeet\\LaravelContactForm\\ContactFormServiceProvider" --tag="contact-form-views"
Mailables
The package includes mailables for sending emails when a contact form is submitted. You can customize these mailables by publishing them to your application's app/Mail directory:
php artisan vendor:publish --provider="CoderManjeet\\LaravelContactForm\\ContactFormServiceProvider" --tag="contact-form-mailables"
Controller
If you need to customize the logic for handling form submissions, you can publish the ContactFormController to your application's app/Http/Controllers directory:
php artisan vendor:publish --provider="CoderManjeet\\LaravelContactForm\\ContactFormServiceProvider" --tag="contact-form-controller"
Migrations
The package includes a migration to create the contacts table. You can customize this migration by publishing it to your application's database/migrations directory:
php artisan vendor:publish --provider="CoderManjeet\\LaravelContactForm\\ContactFormServiceProvider" --tag="contact-form-migrations"
Usage
To use the contact form in your application, simply include the form in one of your views:
@include('laravel-contact-form::contact')
This will render the contact form. When the form is submitted, the data will be stored in the contacts table, and an email will be sent to the configured recipient.
Customizing Form Fields
You can customize the form fields by editing the published views. The default form includes fields for name, email, subject, and message. You can add or remove fields as needed.
Validation
The package includes default validation rules for the form fields. You can customize these rules by editing the config/contact-form.php file.
Email Notifications
When a form is submitted, an email notification is sent to the configured recipient. You can customize the email template by editing the published views in resources/views/vendor/contact-form/mail.
Contributing
Contributions are welcome! Please feel free to submit a pull request or open an issue on GitHub.
License
This package is open-source software licensed under the MIT license.
coder-manjeet/laravel-contact-form 适用场景与选型建议
coder-manjeet/laravel-contact-form 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 02 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 coder-manjeet/laravel-contact-form 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 coder-manjeet/laravel-contact-form 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-02-09