PHPackages                             assada/laravel-user-verification - 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. [Framework](/categories/framework)
4. /
5. assada/laravel-user-verification

ActiveLibrary[Framework](/categories/framework)

assada/laravel-user-verification
================================

User Email Verification For Laravel

v9.0.1(6y ago)043MITPHPPHP &gt;=7.2.0

Since Mar 14Pushed 6y agoCompare

[ Source](https://github.com/assada/laravel-user-verification)[ Packagist](https://packagist.org/packages/assada/laravel-user-verification)[ RSS](/packages/assada-laravel-user-verification/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (7)Versions (105)Used By (0)

**jrean/laravel-user-verification** is a PHP package built for Laravel 5.\* &amp; 6.\* &amp; 7.\* to easily handle a user verification and validate the e-mail.

[![Latest Stable Version](https://camo.githubusercontent.com/7f3e86cdccc2d233108debfe6b48f1bc942bb3073c2f474ffb601e76a205e452/68747470733a2f2f706f7365722e707567782e6f72672f6a7265616e2f6c61726176656c2d757365722d766572696669636174696f6e2f762f737461626c65)](https://packagist.org/packages/jrean/laravel-user-verification) [![Total Downloads](https://camo.githubusercontent.com/4ae64ff9054101cfae3f264d38d75b4cf83b7defe0c8b138c323226b77f2e014/68747470733a2f2f706f7365722e707567782e6f72672f6a7265616e2f6c61726176656c2d757365722d766572696669636174696f6e2f646f776e6c6f616473)](https://packagist.org/packages/jrean/laravel-user-verification) [![License](https://camo.githubusercontent.com/deb336c86ba9ca369a268b11d75d347b205a78440381b3a37d256b045c55ba19/68747470733a2f2f706f7365722e707567782e6f72672f6a7265616e2f6c61726176656c2d757365722d766572696669636174696f6e2f6c6963656e7365)](https://packagist.org/packages/jrean/laravel-user-verification)

VERSIONS
--------

[](#versions)

**This package is Laravel 7.0 compliant.**

laravel/branch[2.2](https://github.com/jrean/laravel-user-verification/tree/2.2)[3.0](https://github.com/jrean/laravel-user-verification/tree/3.0)[4.1](https://github.com/jrean/laravel-user-verification/tree/4.1)[5.0](https://github.com/jrean/laravel-user-verification/tree/5.0)[6.0](https://github.com/jrean/laravel-user-verification/tree/6.0)[7.0](https://github.com/jrean/laravel-user-verification/tree/7.0)[8.0](https://github.com/jrean/laravel-user-verification/tree/8.0)[master](https://github.com/jrean/laravel-user-verification/tree/master)5.0.\*x5.1.\*x5.2.\*x5.3.\*x5.4.\*x5.5.\*x5.6.\*x5.7.\*x5.8.\*x6.0.\*x7.0.\*xABOUT
-----

[](#about)

- Generate and store a verification token for a registered user
- Send or queue an e-mail with the verification token link
- Handle the token verification
- Set the user as verified
- Relaunch the process anytime

INSTALLATION
------------

[](#installation)

This project can be installed via [Composer](http://getcomposer.org). To get the latest version of Laravel User Verification, add the following line to the require block of your composer.json file:

```
{
    "require": {
        "jrean/laravel-user-verification": "dev-master"
    }

}

```

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 jrean/laravel-user-verification

```

### Add the Service Provider &amp; Facade/Alias

[](#add-the-service-provider--facadealias)

Once Larvel User Verification is installed, you need to register the service provider in `config/app.php`. Make sure to add the following line **above** the `RouteServiceProvider`.

```
Jrean\UserVerification\UserVerificationServiceProvider::class,
```

You may add the following `aliases` to your `config/app.php`:

```
'UserVerification' => Jrean\UserVerification\Facades\UserVerification::class,
```

Publish the package config file by running the following command:

```
php artisan vendor:publish --provider="Jrean\UserVerification\UserVerificationServiceProvider" --tag="config"

```

CONFIGURATION
-------------

[](#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

[](#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:

```
php artisan migrate --path="/vendor/jrean/laravel-user-verification/src/resources/migrations"

```

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:

```
php artisan vendor:publish --provider="Jrean\UserVerification\UserVerificationServiceProvider" --tag="migrations"

```

Middleware
----------

[](#middleware)

### Default middleware

[](#default-middleware)

This package provides an optional middleware throwing a `UserNotVerifiedException`. Please refer to the [Laravel Documentation](https://laravel.com/docs/master/errors#the-exception-handler) 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:

```
protected $routeMiddleware = [
    // …
    'isVerified' => \Jrean\UserVerification\Middleware\IsVerified::class,
```

Apply the middleware on your routes:

```
Route::group(['middleware' => ['isVerified']], function () {
    // …
```

### Custom middleware

[](#custom-middleware)

Create your own custom middleware using the following artisan command:

```
php artisan make:middleware IsVerified

```

For more details about middlewares, please refer to the [Laravel Documentation](https://laravel.com/docs/5.3/middleware).

E-MAIL
------

[](#e-mail)

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

- `send(AuthenticatableContract $user, $subject, $from = null, $name = null)`

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

```
    'from' => ['address' => '', 'name' => ''],
```

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

Refer to the Laravel [documentation](https://laravel.com/docs/) for the proper e-mail component configuration.

### E-mail View

[](#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:

```
Click here to verify your account: {{ $link }}

```

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

```
'email' => [
    'type' => 'default',
],
```

by:

```
'email' => [
    'type' => 'markdown',
],
```

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.**

```
php artisan vendor:publish --provider="Jrean\UserVerification\UserVerificationServiceProvider" --tag="views"

```

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

ERRORS
------

[](#errors)

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

- `ModelNotCompliantException`

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

- `TokenMismatchException`

Wrong verification token.

- `UserIsVerifiedException`

The given user is already verified.

- `UserNotVerifiedException`

The given user is not yet verified.

- `UserNotFoundException`

No user found for the given e-mail address.

- `UserHasNoEmailException`

User email property is null or empty.

### Error View

[](#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:

```
php artisan vendor:publish --provider="Jrean\UserVerification\UserVerificationServiceProvider" --tag="views"

```

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

USAGE
-----

[](#usage)

### Routes

[](#routes)

By default this packages ships with two routes.

```
Route::get('email-verification/error', 'Auth\RegisterController@getVerificationError')->name('email-verification.error');
Route::get('email-verification/check/{token}', 'Auth\RegisterController@getVerification')->name('email-verification.check');
```

#### Overriding package 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.

```
   /*
    * Package Service Providers...
    */
    Jrean\UserVerification\UserVerificationServiceProvider::class,

   /*
    * Application Service Providers...
    */
    // ...
    App\Providers\RouteServiceProvider::class,
```

Then, add your custom routes in your route file.

### Traits

[](#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.

- `isVerified` checks if a user is marked as verified.
- `isPendingVerification` checks if a verification process has been initiated for a user.

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

### Endpoints

[](#endpoints)

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

- `getVerification(Request $request, $token)`

Handle the user verification.

- `getVerificationError()`

Do something if the verification fails.

### API

[](#api)

The package public API offers eight (8) methods.

- `generate(AuthenticatableContract $user)`

Generate and save a verification token for the given user.

- `send(AuthenticatableContract $user, $subject = null, $from = null, $name = null)`

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

- `sendQueue(AuthenticatableContract $user, $subject = null, $from = null, $name = null)`

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

- `sendLater($seconds, AuthenticatableContract $user, $subject = null, $from = null, $name = null)`

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

- `process($email, $token, $userTable)`

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

For the `sendQueue`, `sendLater` and `sendLaterOn` methods, you must [configure your queues](https://laravel.com/docs/)before using this feature.

### Facade

[](#facade)

The package offers a facade `UserVerification::`.

### Attributes/Properties

[](#attributesproperties)

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

- `$redirectIfVerified = '/';`

Where to reditect if the authenticated user is already verified.

- `$redirectAfterVerification = '/';`

Where to redirect after a successful verification token verification.

- `$redirectIfVerificationFails = '/email-verification/error';`

Where to redirect after a failling token verification.

- `$verificationErrorView = 'laravel-user-verification::user-verification';`

Name of the view returned by the getVerificationError method.

- `$verificationEmailView = 'laravel-user-verification::email'`

Name of the default e-mail view.

- `$userTable = 'users';`

Name of the default table used for managing users.

### Translations

[](#translations)

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

```
php artisan vendor:publish --provider="Jrean\UserVerification\UserVerificationServiceProvider" --tag="translations"

```

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](https://laravel.com/docs/5.3/localization).

### Auto-login

[](#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:

```
'auto-login' => false,
```

by:

```
'auto-login' => true,
```

### Customize

[](#customize)

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

GUIDELINES
----------

[](#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

[](#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.

- Define the e-mail view.

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

- Import the `VerifiesUsers` trait (mandatory)
- Overwrite and customize the redirect attributes/properties paths available within the `RedirectsUsers` trait included by the `VerifiesUsers` trait. (not mandatory)
- Overwrite the contructor (not mandatory)
- Overwrite the `register()` method (mandatory)

```
    namespace App\Http\Controllers\Auth;

    use App\User;
    use App\Http\Controllers\Controller;
    use Illuminate\Support\Facades\Validator;
    use Illuminate\Foundation\Auth\RegistersUsers;

    use Illuminate\Http\Request;
    use Illuminate\Auth\Events\Registered;
    use Jrean\UserVerification\Traits\VerifiesUsers;
    use Jrean\UserVerification\Facades\UserVerification;

    class RegisterController extends Controller
    {
        /*
        |--------------------------------------------------------------------------
        | Register Controller
        |--------------------------------------------------------------------------
        |
        | This controller handles the registration of new users as well as their
        | validation and creation. By default this controller uses a trait to
        | provide this functionality without requiring any additional code.
        |
        */

        use RegistersUsers;

        use VerifiesUsers;

        /**
         * Where to redirect users after registration.
         *
         * @var string
         */
        protected $redirectTo = '/home';

        /**
         * Create a new controller instance.
         *
         * @return void
         */
        public function __construct()
        {
            // Based on the workflow you need, you may update and customize the following lines.

            $this->middleware('guest', ['except' => ['getVerification', 'getVerificationError']]);
        }

        /**
         * Get a validator for an incoming registration request.
         *
         * @param  array  $data
         * @return \Illuminate\Contracts\Validation\Validator
         */
        protected function validator(array $data)
        {
            return Validator::make($data, [
                'name' => 'required|max:255',
                'email' => 'required|email|max:255|unique:users',
                'password' => 'required|min:6|confirmed',
            ]);
        }

        /**
         * Create a new user instance after a valid registration.
         *
         * @param  array  $data
         * @return User
         */
        protected function create(array $data)
        {
            return User::create([
                'name' => $data['name'],
                'email' => $data['email'],
                'password' => bcrypt($data['password']),
            ]);
        }

        /**
         * Handle a registration request for the application.
         *
         * @param  \Illuminate\Http\Request  $request
         * @return \Illuminate\Http\Response
         */
        public function register(Request $request)
        {
            $this->validator($request->all())->validate();

            $user = $this->create($request->all());

            event(new Registered($user));

            $this->guard()->login($user);

            UserVerification::generate($user);

            UserVerification::send($user, 'My Custom E-mail Subject');

            return $this->registered($request, $user)
                            ?: redirect($this->redirectPath());
        }
    }
```

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.

```
$this->middleware('guest', ['except' => ['getVerification', 'getVerificationError']]);
```

RELAUNCH THE PROCESS ANYTIME
----------------------------

[](#relaunch-the-process-anytime)

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

```
UserVerification::generate($user);
UserVerification::send($user, 'My Custom E-mail Subject');
```

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.

LARAVEL SPARK
-------------

[](#laravel-spark)

For Laravel Spark integration, follow this [article from Ian Fagg](https://medium.com/@idff/laravel-spark-user-verification-75441cff5e44)

CONTRIBUTE
----------

[](#contribute)

Feel free to comment, contribute and help. 1 PR = 1 feature.

LICENSE
-------

[](#license)

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

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 92% of commits — single point of failure

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

Recently: every ~50 days

Total

104

Last Release

2232d ago

Major Versions

v5.0.1 → v6.0.02018-05-09

v6.0.1 → v7.0.02018-09-13

v3.0.25 → v7.0.32019-03-01

v7.0.2 → 8.0.x-dev2019-09-12

2.2.x-dev → v9.0.02020-03-18

PHP version history (5 changes)v1.0PHP &gt;=5.5.9

v3.0.0PHP &gt;=5.6.4

v5.0.0PHP &gt;=7.0.0

v6.0.0PHP &gt;=7.1.3

8.0.x-devPHP &gt;=7.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/a5eec1ae13fb954aa9392fe815fbe6d915a1fa5c7fda4af251c279ccbc8d1d5b?d=identicon)[AlexIlyenko](/maintainers/AlexIlyenko)

---

Top Contributors

[![jrean](https://avatars.githubusercontent.com/u/5646128?v=4)](https://github.com/jrean "jrean (288 commits)")[![DariusIII](https://avatars.githubusercontent.com/u/3399658?v=4)](https://github.com/DariusIII "DariusIII (4 commits)")[![tshafer](https://avatars.githubusercontent.com/u/299464?v=4)](https://github.com/tshafer "tshafer (3 commits)")[![vinothkannans](https://avatars.githubusercontent.com/u/9372109?v=4)](https://github.com/vinothkannans "vinothkannans (3 commits)")[![Clowting](https://avatars.githubusercontent.com/u/7937079?v=4)](https://github.com/Clowting "Clowting (2 commits)")[![Konafets](https://avatars.githubusercontent.com/u/363363?v=4)](https://github.com/Konafets "Konafets (1 commits)")[![assada](https://avatars.githubusercontent.com/u/1472664?v=4)](https://github.com/assada "assada (1 commits)")[![mhanoglu](https://avatars.githubusercontent.com/u/8195419?v=4)](https://github.com/mhanoglu "mhanoglu (1 commits)")[![percymamedy](https://avatars.githubusercontent.com/u/11259669?v=4)](https://github.com/percymamedy "percymamedy (1 commits)")[![rob-union](https://avatars.githubusercontent.com/u/15341419?v=4)](https://github.com/rob-union "rob-union (1 commits)")[![SiiXFX](https://avatars.githubusercontent.com/u/8012245?v=4)](https://github.com/SiiXFX "SiiXFX (1 commits)")[![slowkow](https://avatars.githubusercontent.com/u/209714?v=4)](https://github.com/slowkow "slowkow (1 commits)")[![sobhanatar](https://avatars.githubusercontent.com/u/1507325?v=4)](https://github.com/sobhanatar "sobhanatar (1 commits)")[![lloy0076](https://avatars.githubusercontent.com/u/1174532?v=4)](https://github.com/lloy0076 "lloy0076 (1 commits)")[![blueclock](https://avatars.githubusercontent.com/u/586174?v=4)](https://github.com/blueclock "blueclock (1 commits)")[![chil360](https://avatars.githubusercontent.com/u/3837011?v=4)](https://github.com/chil360 "chil360 (1 commits)")[![DCzajkowski](https://avatars.githubusercontent.com/u/4501047?v=4)](https://github.com/DCzajkowski "DCzajkowski (1 commits)")[![gpressutto5](https://avatars.githubusercontent.com/u/12385501?v=4)](https://github.com/gpressutto5 "gpressutto5 (1 commits)")

---

Tags

frameworklaravelemail-verificationuser verificationuser activationemail activation

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/assada-laravel-user-verification/health.svg)

```
[![Health](https://phpackages.com/badges/assada-laravel-user-verification/health.svg)](https://phpackages.com/packages/assada-laravel-user-verification)
```

###  Alternatives

[jrean/laravel-user-verification

User Email Verification For Laravel

865843.6k7](/packages/jrean-laravel-user-verification)[rebing/graphql-laravel

Laravel wrapper for PHP GraphQL

2.2k7.1M26](/packages/rebing-graphql-laravel)[graham-campbell/markdown

Markdown Is A CommonMark Wrapper For Laravel

1.3k7.1M64](/packages/graham-campbell-markdown)[graham-campbell/manager

Manager Provides Some Manager Functionality For Laravel

39221.1M134](/packages/graham-campbell-manager)[laravel-lang/publisher

Localization publisher for your Laravel application

2167.7M24](/packages/laravel-lang-publisher)[laravel-zero/framework

The Laravel Zero Framework.

3371.4M369](/packages/laravel-zero-framework)

PHPackages © 2026

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