Download the PHP package glw/auto-refresh without Composer
On this page you can find all versions of the php package glw/auto-refresh. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download glw/auto-refresh
More information about glw/auto-refresh
Files in glw/auto-refresh
Package auto-refresh
Short Description A PHP library for auto-refresh using WebSockets
License
Informations about the package auto-refresh
Auto-Refresh PHP Library
Description
Auto-Refresh is a PHP library that enables automatic browser refresh using WebSocket whenever there is a change in the monitored PHP files. This is especially useful during development when you want to see changes live without manual refreshing.
Features
- Monitors changes in PHP files and directories
- Sends signals to the browser for auto-refresh
- Easy to use with simple configuration
Installation
You can install this library using Composer by running the following command:
Add the following JavaScript code to your HTML file to connect to the WebSocket server:
Run the Server
Start the PHP WebSocket server with the following command:
To use the glw/auto-refresh library in Laravel, follow these steps:
-
Install the Library Install the glw/auto-refresh library using Composer:
- Add WebSocket Server to Laravel Create an Artisan command to run the WebSocket server that monitors file changes:
a. Create Artisan Command Run the following command to create an Artisan command:
b. Edit Artisan Command Open the newly created command file at app/Console/Commands/AutoRefreshServerSide.php and edit it as follows:
-
Add JavaScript Client Add the following JavaScript code to your Blade file (e.g., resources/views/welcome.blade.php) to connect to the WebSocket server:
- Run the WebSocket Server Run the newly created Artisan command to start the WebSocket server:
The WebSocket server will now monitor changes in the directories you specified and send a signal to the browser to auto-refresh if there are any changes. Make sure to run this command in the terminal while developing your Laravel application.