Download the PHP package rodshaffer/laravel-user-verification without Composer

On this page you can find all versions of the php package rodshaffer/laravel-user-verification. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-user-verification

rodshaffer/laravel-user-verification is a PHP package built for Laravel 5.6.* to easily handle a user verification and validate the e-mail. This package is a modified clone of "Jean Ragouin's" / jrean/laravel-user-verification package 6.0 branch and has been modified to support the use of Gravatar for user avatar's. ie. The verification process can be re-initiated to verify the new email address and on successful verification the users Gravatar will be re-hashed.

This package supports Laravel 5.6 only.

ABOUT

INSTALLATION

This project can be installed via Composer. To get the latest version of rodshaffer/laravel-user-verification, add the following line to the require block of your composer.json file:

{
    "require": {
        "rodshaffer/laravel-user-verification": "^1.0"
    }

}

You'll then need to run composer install or composer update to download the package and have the autoloader updated.

Or run the following command:

composer require rodshaffer/laravel-user-verification

Publish the package config file by running the following command:

CONFIGURATION

The model representing the User must implement the authenticatable interface Illuminate\Contracts\Auth\Authenticatable which is the default with the Eloquent User model.

Migration

The table representing the user must be updated with two new columns, verified and verification_token. This update will be performed by the migrations included with this package.

It is mandatory that the two columns are on the same table where the user's e-mail is stored. Please make sure you do not already have those fields on your user table.

To run the migrations from this package use the following command:

The package tries to guess your user table by checking what is set in the auth providers users settings. If this key is not found, the default App\User will be used to get the table name.

To customize the migration, publish it with the following command:

Please note: When using Gravatar the table representing the user must be updated with one new column, gravatar to accomplish this publish the migrations with the above artisan command and customize the migration by adding the following.

Also make sure to set the gravatar config value to true

Middleware

Default middleware

This package provides an optional middleware throwing a UserNotVerifiedException. Please refer to the Laravel Documentation to learn more about how to work with the exception handler.

To register the default middleware add the following lines to the $routeMiddleware array within the app/Http/Kernel.php file:

Apply the middleware on your routes:

Custom middleware

Create your own custom middleware using the following artisan command:

For more details about middlewares, please refer to the Laravel Documentation.

E-MAIL

This package provides a method to send an e-mail with a link containing the verification token.

By default the package will use the from and name values defined into the config/mail.php file:

If you want to override the values, simply set the $from and (optional) $name parameters.

Refer to the Laravel documentation for the proper e-mail component configuration.

E-mail View

The user will receive an e-mail with a link leading to the getVerification() method (endpoint). The view will receive a $user variable which contains the user details such as the verification token.

The package allow you to use both traditional blade view files and markdown.

By default a sample e-mail view is loaded to get you started with:

If you prefer to use Markdown instead, update the package config file user-verification.php in the config directory and replace the following:

by:

If you want to customize the e-mail views, run the following command to publish them and edit them to your needs:

The URL must contain the verification token as parameter + (mandatory) a query string with the user's e-mail as parameter.

The view will be available in the resources/views/vendor/laravel-user-verification/ directory.

ERRORS

This package throws several exceptions. You are free to use try/catch statements or to rely on the Laravel built-in exceptions handler.

The model instance provided is not compliant with this package. It must implement the authenticatable interface Illuminate\Contracts\Auth\Authenticatable

Wrong verification token.

The given user is already verified.

The given user is not yet verified.

No user found for the given e-mail address.

User email property is null or empty.

Error View

By default the user-verification.blade.php view will be loaded for the verification error route /email-verification/error. If an error occurs, the user will be redirected to this route and this view will be rendered.

To customize the view, publish it with the following command:

The view will be available in the resources/views/vendor/laravel-user-verification/ directory and can be customized.

USAGE

Routes

By default this packages ships with two routes.

Overriding package routes

To define your own custom routes, put the package service provider call before the RouteServiceProvider call in the config/app.php file.

Then, add your custom routes in your route file.

Traits

The package offers three (3) traits for a quick implementation. Only VerifiesUsers trait is mandatory and includes RedirectsUsers.

Jrean\UserVerification\Traits\VerifiesUsers

Jrean\UserVerification\Traits\RedirectsUsers

and:

Jrean\UserVerification\Traits\UserVerification

This last one offers two methods that can be added to the User model.

Add the use statement to your User model and use the UserVerification within the class:

Endpoints

The two (2) following methods are included into the VerifiesUsers trait and called by the default package routes.

Handle the user verification.

Do something if the verification fails.

API

The package public API offers eight (8) methods.

Generate and save a verification token for the given user.

Send by e-mail a link containing the verification token.

Queue and send by e-mail a link containing the verification token.

Send later by e-mail a link containing the verification token.

Process the token verification for the given e-mail and token.

For the sendQueue, sendLater and sendLaterOn methods, you must configure your queues before using this feature.

Facade

The package offers a facade UserVerification::.

Attributes/Properties

To customize the package behaviour and the redirects you can implement and customize six (6) attributes/properties:

Where to reditect if the authenticated user is already verified.

Where to redirect after a successful verification token verification.

Where to redirect after a failling token verification.

Name of the view returned by the getVerificationError method.

Name of the default e-mail view.

Name of the default table used for managing users.

Translations

To customize the translations you may publish the files to your resources/lang/vendor folder using the following command:

This will add laravel-user-verification/en/user-verification.php to your vendor folder. By creating new language folders, like de or fr and placing a user-verification.php with the translations inside, you can add translations for other languages. You can find out more about localization in the Laravel documentation.

Auto-login

If you wish to automaticaly log in the user after the verification process, update the package config file user-verification.php in the config directory and replace the following:

by:

Customize

You can customize the package behaviour by overriding/overwriting the public methods and the attributes/properties. Dig into the source.

GUIDELINES

This package doesn't require the user to be authenticated to perform the verification. You are free to implement any flow you may want to achieve.

This package wishes to let you be creative while offering you a predefined path. The following guidelines assume you have configured Laravel for the package as well as created and migrated the migration according to this documentation and the previous documented steps.

Note that by default the behaviour of Laravel is to return an authenticated user after the registration step.

Example

The following code sample aims to showcase a quick and basic implementation following Laravel logic. You are free to implement the way you want. It is highly recommended to read and to understand the way Laravel implements registration/authentication.

Edit the app\Http\Controllers\Auth\RegisterController.php file.

At this point, after registration, an e-mail is sent to the user. Click the link within the e-mail and the user will be verified against the token.

If you want to perform the verification against an authenticated user you must update the middleware exception to allow getVerification and getVerificationError routes to be accessed.

RELAUNCH THE PROCESS ANYTIME

If you want to regenerate and resend the verification token, you can do this with the following two lines:

The generate method will generate a new token for the given user and change the verified column to 0. The send method will send a new e-mail to the user.

LICENSE

Laravel User Verification is licensed under The MIT License (MIT).


All versions of laravel-user-verification with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1.3
illuminate/support Version 5.6.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package rodshaffer/laravel-user-verification contains the following files

Loading the files please wait ....