vendor_slug/package_slug

This is my package LaravelHttps
1,166 4
Install
composer require vendor_slug/package_slug
Latest Version:1.1.1
PHP:^7.3|^8.0
Laravel:4 – 9
License:MIT
Last Updated:Feb 7, 2023
Links: GitHub  ·  Packagist
Maintainer: Benjaber-98

Laravel HTTPS Checker

Laravel Https is package is created to check for Secure HTTP requests. Laravel Https provides a middleware to force redirection to HTTPS Protocol.

Latest Version on Packagist Total Downloads

Installation

You can install the package via composer:

composer require benjaber-98/laravel-https

You can publish the config file with:

php artisan vendor:publish

Then choose the number of package service provider from the list.

This is the contents of the published config file:

<?php

return [
    'force_in_local' => env('FORCE_HTTPS_IN_LOCAL', false),
];

By default package is disabled in local environment, if you want to turn it on you can set FORCE_HTTPS_IN_LOCAL in .env file like this:

FORCE_HTTPS_IN_LOCAL=true

Usage

Basic Usage:
  • Add \Benjaber98\LaravelHttps\Middlewares\ForceHttpMiddleware::class to your Kernel file like this:
// 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 Example:
    Route::group(['middleware' => ['force_https']], function () {
        Route::get('/', ['PageController', 'index']);
    });
Individual Route Examples:
    Route::get('/', ['PageController', 'welcome'])->middleware('force_https');
From Controller File:
  • You can include the force_https middleware in the constructor of your controller file.
Controller File Example:
    public function __construct()
    {
       $this->middleware('force_https');
    }

Contributing

Please see CONTRIBUTING for details.

Credits

License

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

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

644,549,754 9,698
laravel/framework

The Laravel Framework.

598,760,099 34,966
laravel/tinker

Powerful REPL for the Laravel framework.

507,193,856 7,441
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

423,477,751 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

403,217,078 4,664

Version History

Version Released PHP Laravel License
1.1.1 ^7.3|^8.0 * MIT
1.1 ^7.3|^8.0 * MIT
1.0.0 ^7.3|^8.0 * MIT