parallax/laravel-protocol

Handles detection of http protocol and changes internal links and redirects

dev-master 2018-03-01 18:15 UTC

This package is auto-updated.

Last update: 2024-03-18 00:32:11 UTC


README

Handles detection of http protocol and changes internal links and redirects to match.

Installation

You will need composer to install this package (get composer). Then run:

composer require parallax/laravel-protocol

Register Service Provider

Add the below into your config/app.php within providers array

Parallax\Protocol\ProtocolServiceProvider::class

After installation you will need to publish the config file. To do this run:

php artisan vendor:publish --tag=protocol.config

This will create the file config/protocol.php where you can configure the settings.

Configuration

auto

If set to true this will automatically match the internal links to the current users protocol.

protocol

If set this will force internal links and redirect users to the set protocol. Accepted values are http or https. Leave blank to not set.

environments

You can add your own name for environments within this array. The key of the array should match your used APP_ENV values for it to detect correctly.

Within each environment you can set https to true or false. If true this will change all internal linking to https. If you set redirect to true then this will force all users to https, but only if you have set https to true.

Example Config
/**
 * Automatically detect based on current protocol
 */
'auto' => false,

/**
 * Force everything to a set protocol either
 * 'http' or 'https'. If blank then won't 
 * force anything. Ignored if 'auto' is true.
 */
'protocol' => '',

/**
 * Use different rules per environment
 * Ignored if 'auto' is true or 'protocol' is set.
 */
'environments' => [
    'local' => [
        'https' => false,
        'redirect' => false
    ],
    'production' => [
        'https' => true,
        'redirect' => false
    ]
]