PHP code example of hiraeth / middleware-browser-redirect
1. Go to this page and download the library: Download hiraeth/middleware-browser-redirect library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hiraeth / middleware-browser-redirect example snippets
//
// The factory must be an actual instance of a response factory, the PSR interface here is
// used as a stand in for any particular PSR compatible implementation.
//
$factory = new Psr\Http\Message\ResponseFactoryInterface();
$browser = new Sinergi\BrowserDetector\Browser();
$redirect = new BrowserRedirect($browser, $factory);
$redirect->addRule([
'target' => '/.*',
'browser' => 'IE',
'version' => '<10',
'redirect' => 'https://getfirefox.com'
]);
//
// This will actually be executed by your middleware stack, so you probably don't need to do this
// yourself.
//
$response = $redirect->process($request, $handler);