Download the PHP package klevze/online-users without Composer

On this page you can find all versions of the php package klevze/online-users. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package online-users

Laravel plugin for displaying online users on a webpage

You can also set these variables in your .env file (example below).

Latest Version on Packagist GitHub Tests Action Status

Laravel 12 Laravel 12 GitHub Code Style Action Status Total Downloads

Note: This repository currently runs CI only for Laravel 12. The older per-version workflow files for Laravel 10 and 11 were removed to simplify the workflow matrix and remove duplicate CI runs. If you need per-Laravel-version badges again, recreate the per-version workflows or restore run-tests-laravel-10.yml and run-tests-laravel-11.yml.

"Online Users" is a Laravel package designed to effortlessly track and display the real-time count of users currently active on your web application. With seamless integration, this package provides a quick and reliable solution for monitoring and presenting the dynamic online user presence, enhancing the overall user experience on your Laravel-powered website.

Installation

You can install the package via composer:

You can publish and run the migrations and configuration with:

Integration with Laravel's Kernel Middleware

To enable the "Online Users" middleware in your Laravel application, follow these steps:

  1. Open the app/Http/Kernel.php file in your Laravel project.

  2. Locate the $middlewareGroups property, specifically within the web middleware group.

  3. Add the following line to the web middleware group:

The "CleanupInactiveUsers" console command provided by the "Online Users" package allows you to remove inactive users from the user_activities table. Follow the steps below to integrate and schedule the cleanup task.

  1. Open the app/Console/Kernel.php file in your Laravel project.

  2. Locate the schedule method and add the following entry to schedule the cleanup:inactive-users command every five minutes:

  3. Save the changes to the Kernel.php file.

Now, the "CleanupInactiveUsers" console command will run every five minutes, cleaning up inactive users from the user_activities table.

Usage

Once package is installed, you can use the OnlineUsers class to get the number of active users. For example, the following code will get the number of active users:

Or you can use it directly in blade view:

env ONLINE_USERS_ANONYMIZE_IP=true ONLINE_USERS_IP_SALT=your-long-random-salt bash php artisan vendor:publish --tag="online-users-migrations" php artisan migrate bash php artisan online-users:populate-ip-hash bash php artisan vendor:publish --tag="online-users-migrations" php artisan migrate



Before dropping raw IPs, please ensure you have a backup of your database. Recommended workflow:

1. Make a backup of your database.
2. Run `php artisan migrate` to add `user_ip_hash` (if not already present).
3. Run `php artisan online-users:populate-ip-hash` to fill the `user_ip_hash` column.
4. Verify data and application functionality.
5. If all good, run `php artisan migrate` which will pick up the `drop` migration to remove the `user_ip` column.

**Note:** hashing is irreversible; if you need the raw IP for logging, do not enable this option.

## Demo

You can see a working demo at these sites:

- [The Wallpapers](https://thewallpapers.net)
- [Joke Station](https://jokestation.org)

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

## Automated Code Style Fixes

This project runs `php-cs-fixer` in CI. To allow the code-style workflow to auto-commit fixes back to pull requests, add a repository secret named `STYLE_BOT_TOKEN` with a personal access token (PAT) that has `repo` permissions. When set, the workflow will commit fixes directly to the PR branch.

If you do not set `STYLE_BOT_TOKEN`, the workflow will attempt to use the default `GITHUB_TOKEN` where permitted (works for branches in the same repository but not for PRs from forks).

When the workflow runs on a PR it will now create a new pull request with automatic style fixes (rather than pushing changes directly to the originating branch). The original PR will receive a comment linking to the fixes PR.

All versions of online-users with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
illuminate/support Version ^10 || ^11 || ^12
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package klevze/online-users contains the following files

Loading the files please wait ...