1. Go to this page and download the library: Download benjaber-98/laravel-https library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
benjaber-98 / laravel-https example snippets
// app/Http/Kernel.php
...
//use it globally for all requests
protected $middleware = [
...
\Benjaber98\LaravelHttps\Middlewares\ForceHttpMiddleware::class,
];
...
// Or use it globally for all web requests
protected $middlewareGroups = [
'web' => [
...
\Benjaber98\LaravelHttps\Middlewares\ForceHttpMiddleware::class,
],
...
//Or register it to use in routes
protected $routeMiddleware = [
...
'force_https' => \Benjaber98\LaravelHttps\Middlewares\ForceHttpMiddleware::class,
];
Route::group(['middleware' => ['force_https']], function () {
Route::get('/', ['PageController', 'index']);
});