Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Lexorank Php

Lexorank Php Laravel Package

alexcrawford/lexorank-php

Simple PHP implementation of Atlassian JIRA’s LexoRank for ordering database lists. Reorder items in O(1) by updating only the moved row’s rank value, avoiding mass updates and costly transactions.

View on GitHub
Deep Wiki
Context7

At a glance

Frequently asked questions about Lexorank Php
How do I install lexorank-php in a Laravel project?
Use Composer: `composer require alexcrawford/lexorank-php`. Register the service provider in `config/app.php` under `providers`, then bind it in `AppServiceProvider` with `app()->singleton(Lexorank::class, fn() => new Lexorank());`. For quick use, autoload the class directly.
Does lexorank-php work with Laravel Eloquent models?
Yes. Store lexorank strings as VARCHAR in your database, then create custom Eloquent scopes like `scopeOrderedByRank()` to sort queries in-memory. For large datasets, cache sorted results in Redis to avoid repeated string comparisons.
What Laravel versions does this package support?
lexorank-php is PHP 8.0+ compatible and works with Laravel 8.x, 9.x, and 10.x. It’s framework-agnostic but designed for Laravel’s dependency injection. Tested with PHPUnit for edge cases like concurrent writes.
Can I use lexorank for a real-time kanban board with drag-and-drop?
Absolutely. LexoRank’s O(1) insertion makes it ideal for drag-and-drop UIs. Store ranks in your database, update them atomically via transactions, and sort client-side or in-memory. For high concurrency, use Redis for lock-free rank generation.
How does lexorank handle collisions or duplicate ranks?
LexoRank is mathematically designed to avoid collisions. Each rank string is unique and collision-resistant, even with millions of items. No hashing or randomness is involved—just deterministic string generation.
Will lexorank strings bloat my database over time?
String length grows logarithmically with list size (e.g., ~20 chars for 10k items). For very large lists, monitor storage and consider hybrid approaches: use lexorank for dynamic sections and auto-increment IDs for static ones.
How do I migrate an existing ordered list (e.g., ORDER BY id) to lexorank?
Start with a shadow mode: dual-write lexorank strings alongside your current IDs. Gradually replace queries with lexorank-based sorting. For Eloquent, add a `lexorank` column and backfill it using `Lexorank::insertAfter($lastRank)` for each item.
Is lexorank-php faster than PostgreSQL’s list type or MongoDB’s $sort?
LexoRank excels in **insertion speed** (O(1) vs. O(n) for numeric IDs). For **query speed**, PostgreSQL’s list type or MongoDB’s native sorting may outperform PHP-side string comparisons. Benchmark your use case—lexorank shines in dynamic, high-write scenarios.
How do I handle concurrent rank updates in a distributed Laravel app?
Use database transactions or Redis locks to prevent race conditions. For example, wrap rank updates in `DB::transaction()` or use `Redis::lock()`. Avoid optimistic locking unless your system has low contention.
Are there alternatives to lexorank-php for Laravel?
For Laravel, alternatives include: **PostgreSQL’s `list` type** (native sorting), **MongoDB’s `$sort` with custom logic**, or **numeric IDs with `position` columns** (but O(n) updates). LexoRank stands out for portability and O(1) inserts across databases.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
codifyo/ts-generator-bundle
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor