GithubHelp home page GithubHelp logo

laravel-https's Introduction

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.

laravel-https's People

Contributors

benjaber-98 avatar

Stargazers

 avatar Yousef Breaka avatar Lazord El-Fizga avatar Muna El-Boashi avatar

Watchers

James Cloos avatar  avatar Yousef Breaka avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.