Open Source Developer

Yan Gusik

Building tools for

~/projects
$ composer require yangusik/balanced-queue
✓ Package installed — fair job distribution enabled
$ phppad --connect ssh://prod-server
✓ Connected · PHP 8.2 · Laravel 11 · LSP ready
$

Projects

Laravel Balanced Queue

A Laravel package for queue management with load balancing between partitions (user groups). Perfect for scenarios where you need fair job distribution and concurrency control per user/tenant.

User A
User B
User C
Queue
A
A
A
A
B
C
C
W1
W2
⚠ User A floods the queue. B and C are starved.

Installation

bash
composer require yangusik/balanced-queue
bash
php artisan vendor:publish --tag="balanced-queue-config"
Redis-based — high-performance, low-latency queue management
🔄
Laravel Horizon — experimental dashboard integration included

Configuration

config/balanced-queue.php
return [
    'connection' => env('BALANCED_QUEUE_CONNECTION', 'redis'),

    // Strategy: 'round-robin' | 'random' | 'smart'
    'strategy' => 'round-robin',

    // Max concurrent jobs per partition
    'limiter' => [
        'driver' => 'simple', // 'simple' | 'adaptive' | 'none'
        'max_concurrent' => 2,
    ],

    'queue' => env('BALANCED_QUEUE_NAME', 'default'),
];

Usage

app/Jobs/ProcessReport.php
use YanGusik\BalancedQueue\Traits\HasBalancedQueue;

class ProcessReport implements ShouldQueue
{
    use HasBalancedQueue;

    public function __construct(
        private User $user,
        private Report $report,
    ) {}

    // Partition key — one partition per user
    public function partitionKey(): string
    {
        return 'user:' . $this->user->id;
    }
}
Dispatching
// Dispatch normally — balancing is automatic
ProcessReport::dispatch($user, $report);
bash — Monitoring
php artisan balanced-queue:table  # Show live stats
php artisan balanced-queue:clear  # Clear all partitions

Selection Strategies

Smart

Prioritizes partitions with fewer jobs. Helps clear smaller queues faster but may not be perfectly fair.

strategy: 'smart'
Random

Randomly selects the next partition. Simple, low overhead, statistically fair over time.

strategy: 'random'

PHPPad

Interactive PHP REPL for Laravel. Run code on remote servers via SSH or Docker — right from your desktop or inside PhpStorm.

PHPPad — prod-server (SSH)
⚡ LSP
▶ Artisan
📋 Snippets
📜 History
📄 Logs
1$users = User::limit(10)->get(); //?
2
3$active = $users->where('active', true);//?
← Collection(10)
4dump($active->count());
Output · 42ms · PHP 8.2
$users
Collection(10) [▼
User { id: 1, name: "Alice", … },
User { id: 2, name: "Bob", … },
]
SQL Queries (2)
2ms SELECT * FROM `users` LIMIT 10
1ms SELECT COUNT(*) FROM `users` WHERE `active` = 1
🔌
SSH & Docker
Connect to any remote server or Laravel Sail container. Test connection before saving.
Magic Comments
Add //? after any expression to see its value inline — no var_dump() needed.
LSP Autocomplete
Powered by phpactor. Class/method completion with auto-use imports.
🗄
SQL Query Log
Every query captured with execution time and bound parameters.
🎨
8 Themes
Catppuccin, Dracula, Nord, Tokyo Night, Rosé Pine, One Dark, GitHub Light…
📜
Snippets & History
Save reusable code, browse past 100 executions with search.

Magic Comments

PHP
// Capture line value
$users = User::find(36)->id; //?  →  ← 36

// Capture mid-chain (passes original through)
collect([1,2,3])/*?*/->count()/*?*/->map(fn($x) => $x * 2);
// ← [1,2,3]    ← 3

// Timing (ms since script start)
heavyOperation(); /*?.*/  →  ← 142ms