PHP code example of yaroslawww / laravel-force-https

1. Go to this page and download the library: Download yaroslawww/laravel-force-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/ */

    

yaroslawww / laravel-force-https example snippets


    //app/Http/Kernel.php
	
    /**
     * The application's route middleware.
     *
     * @var array
     */
    protected $routeMiddleware = [
        /**** OTHER MIDDLEWARE ****/
        'https' => \ForceHttps\Middleware\RedirectToHttps::class,
        // REDIRECTION MIDDLEWARE
    ];


	// /routes/web.php

	Route::middleware('https')
        ->group(function() {
            /** ADD ALL SECURE ROUTES INSIDE THIS GROUP **/
            Route::get('/', function()
            {
                //
            });
    
            Route::get('test',function()
            {
                //
            });
        });

	/** OTHER PAGES THAT SHOULD NOT BE SECURE **/

sh
php artisan vendor:publish --provider="ForceHttps\ServiceProvider"
sh

php artisan vendor:publish --provider="ForceHttps\ServiceProvider" --force