Skip to content

ilvalerione/laravel-https-redirect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel https redirect

Build Status Latest Stable Version License

Flexible https redirect for Laravel based applications

Install

composer require ilvalerione/laravel-https-redirect

Config

php artisan vendor:publish --provider="Aventure\HttpsRedirect\HttpsRedirectServiceProvider"

This command publish a new configuration file in your config directory to list all environment names that you want force to https:

return [
    'environments' => [
        // 'local', <-- usually no
        'development',
        'test',
        'production',
    ]
]

Or you can force all possible environment using wildcard:

return [
    'environments' => '*'
]

Use

Add HttpsMiddleware middleware in your global middleware section:

class Kernel extends HttpKernel
{
    /**
     * The application's global HTTP middleware stack.
     *
     * These middleware are run during every request to your application.
     *
     * @var array
     */
    protected $middleware = [
        ...,
        
        \Aventure\HttpsRedirect\Middleware\HttpsCheck::class,
    ];
    
    ...

Use as Route-Middleware

In alternative you can add middleware as named middleware in your Kernel file:

class Kernel extends HttpKernel
{
    /**
     * The application's global HTTP middleware stack.
     *
     * These middleware are run during every request to your application.
     *
     * @var array
     */
    protected $routeMiddleware  = [
        ...,
        
        'https_redirect' => \Aventure\HttpsRedirect\Middleware\HttpsCheck::class,
    ];
    
    ...

And use it programmatically in your routes configuration:

Route::middleware('https_redirect')->group(function(){

    Route::view('example', 'example');
    
});

LICENSE

This package are licensed under the MIT license.

About

Flexible https redirect for Laravel based applications

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages