padosoft/laravel-https

Force redirect to https for Laravel.

1.1.0 2018-08-17 14:24 UTC

This package is auto-updated.

Last update: 2024-12-05 06:40:30 UTC


README

Latest Version on Packagist Software License Quality Score Build Status Total Downloads

This package provides a laravel middleware to force https redirect.

Table of Contents

##Requires

  • "php" : ">=5.6.0",
  • laravel/framework": "~5.2"

Installation

You can install the package via composer:

$ composer require padosoft/laravel-https

FOR LARAVEL 5.6+

No additional steps required because the service provider use new L5.5+ autodiscovery feature.

FOR LARAVEL <=5.5

You must install this service provider.

// config/app.php
'provider' => [
    ...
    Padosoft\Laravel\Https\LaravelHttpsServiceProvider::class,
    ...
];

publish config (optional)

Optionally publish the packages config file by running the following from your projects root folder:

    php artisan vendor:publish --tag=laravel-https

register the middleware

Add the middleware to your routes or controller. See Usage.

USAGE

From Route File:

You can include the HttpsForce in a route groups or on individual routes.

Route Group Example:

    Route::group(['middleware' => ['web', 'HttpsForce']], function () {
        Route::get('/', 'WelcomeController@welcome');
    });

Individual Route Examples:

    Route::get('/', 'WelcomeController@welcome')->middleware('HttpsForce');
    Route::match(['post'], '/test', 'Testing\TestingController@runTest')->middleware('HttpsForce');

From Controller File:

You can include the HttpsForce in the constructor of your controller file.

Controller File Example:

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
       $this->middleware('HttpsForce');
    }

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email instead of using the issue tracker.

Credits

About Padosoft

Padosoft (https://www.padosoft.com) is a software house based in Florence, Italy. Specialized in E-commerce and web sites.

License

The MIT License (MIT). Please see License File for more information.