Download the PHP package kevinorriss/contactform without Composer
On this page you can find all versions of the php package kevinorriss/contactform. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kevinorriss/contactform
More information about kevinorriss/contactform
Files in kevinorriss/contactform
Package contactform
Short Description A basic contact form of email address, message and Google ReCaptcha validation
License MIT
Homepage https://github.com/kevinorriss/contactform
Informations about the package contactform
ContactForm
A simple contact form where a user enters their email address, message and passes a Google reCAPTCHA robot test. The message is then sent to the configured email address.
How it works
This library adds contact form functionality to your Laravel application. Two new routes (get and post) are set up under the "contact" url. A view needs to be set up, but this library provides a partial containing the form HTML, or you may create your own view with application specific layout and CSS styles.
Installation
-
Add ContactForm to your composer.json file under
require
:"kevinorriss\contactform": "1.1.*"
-
Add the ContactFormServiceProvider to your app.php file:
KevinOrriss\ContactForm\ContactFormServiceProvider::class,
- Run
composer update
Usage
Google reCAPTCHA
This library makes use of Google's reCAPTCHA to help stop the contact form being spammed. In order to use this follow these steps:
-
Follow the
Usage
section from Google's reCAPTCHA READMME file, to generate a site key and secret for your application. - Add your reCAPTCHA secret and key to your application environment file, for example:
Email configuration
You must first set up your mail driver, please refer to the Laravel documentation for this.
- Add the following to your application's environment file
This is the email address that the users message will be sent to.
- Add these optional settings to your environment file
These allow you to override the subject of the email and also the flash message that the users sees when the email is sent successfully.
Example
A simple view
To get going, create a file named contact.blade.php
in the resources/views
folder and
add the following:
This form uses Bootstrap for style which is included in the contactform::stylesheet
partial.
When including the form itself, you can provide an optional array with a heading key which overrides the panel heading (defaults to "Contact Form").
By default, the contact form controller will look for contact.blade.php
, you can
override this by creating an entry in your application's environment file such as:
CONTACT_FORM_VIEW="mycontactformview"
You will then need to name your view file to match this.
Javascript
The contactform::javascript
partial includes three extra partials, one each for:
- jQuery (contactform::jquery)
- Bootstrap (contactform::bootstrap)
- reCAPTCHA (contactform::recaptcha)
If your template already includes jQuery or bootstrap, or you simply do not want to
use bootstrap then you can replace the contactform::javascript
partial and use
only the ones you need.
Authors
- Kevin Orriss - Website
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE file for details