PHP code example of klevze / online-users

1. Go to this page and download the library: Download klevze/online-users 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/ */

    

klevze / online-users example snippets


   protected $middlewareGroups = [
       'web' => [
           // ... other middleware entries
           \Klevze\OnlineUsers\Middleware\TrackUserActivity::class,
           // ... other middleware entries
       ],
       // ... other middleware groups
   ];
    

    protected function schedule(Schedule $schedule)
    {
        // ... other scheduled tasks

        $schedule->command('cleanup:inactive-users')->everyFiveMinutes();

        // ... other scheduled tasks
    }
    

$activeUsers = OnlineUsers::getActiveUsers();
bash
php artisan vendor:publish --tag="online-users-migrations"
php artisan migrate
html
<p>Currently browsing: {{ OnlineUsers::getActiveUsers() ?? 0 }}</p>