Download the PHP package tutortonym/laravel-subscriber without Composer
On this page you can find all versions of the php package tutortonym/laravel-subscriber. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tutortonym/laravel-subscriber
More information about tutortonym/laravel-subscriber
Files in tutortonym/laravel-subscriber
Package laravel-subscriber
Short Description Laravel Subscriber allows you to quickly integrate a subscribe/newsletter form to your laravel application.
License MIT
Homepage https://tutortonym.com/packages/laravel/laravel-subscriber
Informations about the package laravel-subscriber
laravel-subscriber
This package allows you to add a subscription/newsletter form to your laravel application without having to create everything from scratch. It also helps you protect your subscription form with Google reCAPTCHA by integrating it with simple entries to your .env file.
This package sends the form via ajax call so there is no page refresh. Due to its use of ajax calls it depends on jQuery being installed on your project.
A nickname for this package is ttm-subscriber and we may refer to it that way throughout this document.
Documentation
The official and more in detailed documentation for this package can be found at https://tutortonym.com/packages/laravel/laravel-subscriber.
Compatibility
This package is compatible with Laravel 5.7 and above.
Dependencies
This package is dependent on jQuery 3 or above.
How to Use
- Install the package
- Publish the public files
- Add the style and script components
- Add the form and modals components
- Optionally, you can add attributes to the form
That is all you need to use this package. However, if you want to make use of Google Re-Captcha v2 to protect your form from spambots, you will need to complete one more step.
- Add the needed fields to the .env file with their corresponding values
Installation
You can install the package via composer:
The package will automatically register itself, and it will be ready to use.
Publishing Files
You can publish certain files by using the artisan command vendor:publish as such:
Adding Components
You will have to add certain components to your views as they are the link between all modules in this package.
Style Component
The style component adds the style tag with the path to the corresponding stylesheet. This component must go in the head of the page.
Script Component
The script component adds the script tag with the path to the corresponding javascript file. This component must go after the jQuery script tag, preferably at the bottom of the body.
Form Component
The form component adds the form that will be used to enter the email address to subscribe to your newsletter. This component should be place where you want to show the subscribe field.
Modals Component
The modals component adds the modal responsible for the alerts (success or fail) after submitting the form and a modal to display the re-captcha checkbox. This component can be place anywhere in the page as it is not visible until it gets triggered, but it is recommended to be placed towards the bottom of the page.
Form Attributes
There are certain values that can be modified on the form by simple variables. The following list shows the variables that can be added to the form component to modify the text on the form:
- $labelText = Modifies the label shown above the input element (default: Subscribe for Special Offers).
- $inputText = Modifies the placeholder used in the input element (default: Enter your Email).
- $buttonText = Modifies the text used in the submit button (default: SUBMIT).
We can modify any or all three by assigning a new value to each variable.
We can also add attributes to the form such as class. By giving the form a class we can add some style to it.
To learn about more advaced ways to manipulate the form refer to the official documentation.
Using Google Re-Captcha
If you want to protect your form from spambots using re-captcha, first you'll need Google reCAPTCHA account. Getting an account is easy, but it is outside the scope of this documentation. You can do a Google search and find plenty of help on this topic.
Once you have a Google reCAPTCHA account you will need to register your domain/site. If you are on development make sure to register localhost and 127.0.0.1. Again, this is outside the scope of this documentation.
Once you have registered your domain and have the appropriate keys, all you have to do is add three entries to your .env file.
The "GOOGLE_RECAPTCHA" entry set to true will enable all functionality to make use of Google re-captcha v2.
The other two entries "GOOGLE_RECAPTCHA_SITE_KEY" and "GOOGLE_RECAPTCHA_SECRET_KEY" will identify your domain to the Google API when making re-captcha calls.
More Advanced Settings
This package has a lot more settings that can be configured to your needs such as change the text on the alert and re-captcha modals, add properties to the inner elements of the form and more. For a more complete list of features visit the official documentation.
About TutorTonyM
I'm a developer from the United States who creates software and websites on a daily basis. I'm passionate about what I do, and I like to share the knowledge I possess. I share my knowledge on different platforms such as YouTube.com/TutorTonyM and TutorTonyM.com. You can follow me on my social media @TutorTonyM on Facebook, Instagram, and Twitter.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-subscriber with dependencies
laravel/framework Version ^5.7|^6.0|^7.0|^8.0|^9.0
guzzlehttp/guzzle Version ^7.4
ext-json Version *