PHP code example of kaantanis / url-tracker

1. Go to this page and download the library: Download kaantanis/url-tracker 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/ */

    

kaantanis / url-tracker example snippets


return [
    'prefix' => 'url-tracker', // example.com/url-tracker/QSGHG2
    'check-last-visit-minute' => 30 // check last 30 min same user visited this url. if not, increase view count
];

// Send post request to this url with tracked_url parameter
// example.com/url-tracker/generate-url (route name is url-tracker.generate-url)

Http::post(route('url-tracker.generate-url'), [
    'tracked_url' => 'https://google.com'
]);

// This return a string url path like this with a unique code
// example.com/url-tracker/QSGHG2

// If any visitor visit this url, user redirect to tracked_url
// and visitor data will be stored in database

// main table
[
    'created_by' => auth()->id() ?? null,
    'url' => $request->tracked_url,
    'placeholder' => $uniqueCode
]

// and log table
[
    'url_tracker_table_id' => $urlFound->id,
    'ip_address' => request()->ip(),
    'user_agent' => request()->userAgent(),
    'referer' => request()->headers->get('referer'),
    'method' => request()->method(),
]
bash
php artisan install:url-tracker