PHP code example of glw / auto-refresh

1. Go to this page and download the library: Download glw/auto-refresh 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/ */

    

glw / auto-refresh example snippets




namespace App\Console\Commands;

use Illuminate\Console\Command;
use Glw\AutoRefresh\AutoRefreshServer;

class AutoRefreshServerSide extends Command
{
    protected $signature = 'auto-refresh:serve';
    protected $description = 'Start the Auto-Refresh WebSocket server';

    public function __construct()
    {
        parent::__construct();
    }

    public function handle()
    {
        $watchedFiles = [
            base_path('app'),       // Monitor app directory
            base_path('resources'), // Monitor resources directory
            base_path('routes'),    // Monitor routes directory
            // Add other directories you want to monitor
        ];

        AutoRefreshServer::runServer($watchedFiles);
    }
}
bash
php examples/example.php
bash
php artisan make:command AutoRefreshServerSide
bash
php artisan auto-refresh:serve