This Laravel package makes it possible for you to set your website in "Under Construction" mode. Only users with the correct 4 digits code can access your site. This package can be useful for you to show your website to a specific client. Everything works out of the box, and it's fully customizable.
Begin by installing this package through Composer.
composer require larsjanssen6/underconstruction
Then the service provider
must be installed.
Laravel 5.5+ users: this step may be skipped, as we can auto-register the package with the framework.
// config/app.php
'providers' => [
'...',
'LarsJanssen\UnderConstruction\UnderConstructionServiceProvider'
];
The \LarsJanssen\UnderConstruction\UnderConstruction::class
middleware must be registered in the kernel:
//app/Http/Kernel.php
protected $routeMiddleware = [
...
'under-construction' => \LarsJanssen\UnderConstruction\UnderConstruction::class,
];
Publish the default configuration file.
php artisan vendor:publish
// Or...
php artisan vendor:publish --provider="LarsJanssen\UnderConstruction\UnderConstructionServiceProvider"
This package is fully customizable. This is the content of the published config file under-construction.php
:
return [
/**
* Activate under construction mode.
*/
'enabled' => env('UNDER_CONSTRUCTION_ENABLED', true),
/**
* Under construction title.
*/
'title' => 'Under Construction',
/**
* Back button translation.
*/
'back-button' => 'back',
/**
* Redirect url after a successful login.
*/
'redirect-url' => '/',
/**
* Enable throttle (max login attempts).
*/
'throttle' => true,
/*
|--------------------------------------------------------------------------
| Throttle settings (only when throttle is true)
|--------------------------------------------------------------------------
|
*/
/**
* Set the maximum number of attempts to allow.
*/
'max_attempts' => 3,
/**
* Show attempts left.
*/
'show_attempts_left' => true,
/**
* Attempts left message.
*/
'attempts_message' => 'Attempts left: %i',
/**
* Too many attempts message.
*/
'seconds_message' => 'Too many attempts please try again in %i seconds.',
/**
* Set the number of minutes to disable login.
*/
'decay_minutes' => 5
];
You'll have to set a 4 digit code. You can do that by running this custom
artisan command (in this example the code is 1234
,you can obviously set another code).
php artisan code:set 1234
You can set routes to be in "Under Construction" mode by using the under-construction
-middleware on them.
Route::group(['middleware' => 'under-construction'], function () {
Route::get('/live-site', function() {
echo 'content!';
});
});
Please see CHANGELOG for more information on what has changed recently.
composer test
I would love to hear your ideas to improve my codeing style and conventions. Feel free to contribute.
If you discover any security related issues, please email mail@larsjanssen.net. You can also make an issue.
I'm Lars Janssen from The Netherlands and like to work on web projects. You can follow me on twitter.
The MIT License (MIT). Please see License File for more information.