Handles detection of http protocol and changes internal links and redirects
jsefton/laravel-protocol is a Laravel package for handles detection of http protocol and changes internal links and redirects.
It currently has 1 GitHub stars and 21 downloads on Packagist (latest version 1.0.0).
Install it with composer require jsefton/laravel-protocol.
Discover more Laravel packages by jsefton
or browse all Laravel packages to compare alternatives.
Last updated
Handles detection of http protocol and changes internal links and redirects to match.
You will need composer to install this package (get composer). Then run:
composer require jsefton/laravel-protocol
Add the below into your config/app.php within providers array
JSefton\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.
autoIf set to true this will automatically match the internal links to the current users protocol.
protocolIf set this will force internal links and redirect users to the set protocol. Accepted values are http or https. Leave blank to not set.
environmentsYou 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.
/**
* 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
]
]