1. Go to this page and download the library: Download spatie/laravel-referer 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/ */
spatie / laravel-referer example snippets
return [
/*
* The key that will be used to remember the referer in the session.
*/
'session_key' => 'referer',
/*
* The sources used to determine the referer.
*/
'sources' => [
Spatie\Referer\Sources\UtmSource::class,
Spatie\Referer\Sources\RequestHeader::class,
],
];
namespace App\Referer;
use Illuminate\Http\Request;
use Spatie\Referer\Source;
class RefParameter implements Source
{
public function getReferer(Request $request): string
{
return $request->get('ref', '');
}
}