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

Laravel Linkable Laravel Package

novius/laravel-linkable

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Eloquent-Centric: Perfect for Laravel apps where models need resolvable, queryable links (e.g., CMS, knowledge bases, or SaaS with relational data). Avoids reinventing pivot tables or custom relationship logic.
  • URL Resolution: Handles dynamic route generation (e.g., localized paths, query params) via getUrlCallback, reducing manual route() calls in models.
  • Nova/Filament Integration: Provides pre-built UI fields for link management, accelerating admin panel development.
  • Query Flexibility: Supports filtered queries (e.g., optionsQuery, resolveQuery) to scope linkable models (e.g., "only published posts").
  • Limitations:
    • Not a Graph Database: No traversal algorithms (e.g., "find all posts linked within 2 hops").
    • No Built-in Validation: Circular links or permission checks require custom logic.
    • AGPL License: May block proprietary projects (mitigate via forking).

Technical Risk

  • Dependency Risk: Tied to Laravel 10+ and PHP 8.2+. Downgrading could require forks.
  • Configuration Complexity: LinkableConfig requires careful setup (e.g., routeName, optionLabel). Misconfigurations may break URL generation.
  • Localization Dependencies: Assumes Laravel’s localization system. Custom route callbacks (e.g., for Spatie’s laravel-translatable) may be needed.
  • Testing Gaps: Low stars/dependents suggest unproven scalability. Critical: Test with:
    • High-cardinality links (e.g., 10K+ relationships).
    • Concurrent writes (race conditions on linkable pivot tables).
    • Edge cases (e.g., deleted models, soft deletes).

Key Questions

  1. Does our app need dynamic URL resolution (e.g., slugs, query params) or static routes?
  2. Will we use Nova/Filament? If not, the UI fields add unnecessary complexity.
  3. How critical is link integrity? (e.g., "Can we tolerate orphaned links?" → Use resolveQuery to filter.)
  4. License Compliance: Can we use AGPL, or must we fork/relicense?
  5. Performance: Will optionsQuery scans (e.g., published()) impact Nova field load times?
  6. Future Needs: Do we need link metadata (e.g., timestamps, user IDs) or graph traversal? If yes, this package may not suffice long-term.

Integration Approach

Stack Fit

  • Ideal For:
    • Laravel 10+ apps with Eloquent models needing links (e.g., Post, Product, Article).
    • Projects using Nova/Filament for admin UIs (reduces custom field development).
    • Systems requiring URL generation tied to model instances (e.g., SEO-friendly slugs).
  • Poor Fit:
    • Non-Laravel stacks (e.g., Symfony, Django).
    • Apps needing graph algorithms (e.g., pathfinding).
    • Projects with strict proprietary licensing.

Migration Path

  1. Pilot Phase:
    • Apply the trait to one model (e.g., Post).
    • Test URL generation ($post->url()) and Nova field rendering.
    • Validate optionsQuery performance (e.g., published() filter).
  2. Core Integration:
    • Publish configs (php artisan vendor:publish) for customization.
    • Replace ad-hoc belongsToMany relationships with Linkable where possible.
    • Add getUrlCallback for domain-specific routes (e.g., /posts/{slug}).
  3. UI Layer:
    • Replace custom Nova fields with Linkable::make().
    • Configure optionSearch for discoverability (e.g., search by title or slug).
  4. Edge Cases:
    • Handle soft deletes via resolveQuery (e.g., ->whereNotNull('deleted_at')).
    • Implement fallback URLs for broken links (e.g., previewUrl() with tokens).

Compatibility

  • Laravel: Requires 10.x. Downgrading to 9.x would need forks of the package.
  • PHP: 8.2+ (no 7.4 support).
  • Dependencies:
    • Nova/Filament: Only for UI fields. Core trait works without them.
    • Localization: Assumes Laravel’s locale system. Override setRouteCallback if using Spatie’s translatable or similar.
  • Database: No schema changes, but pivot tables are implied for many-to-many links (e.g., post_linkables).

Sequencing

  1. Pre-Reqs:
    • Upgrade to Laravel 10/PHP 8.2 if needed.
    • Audit existing link logic (e.g., custom hasManyThrough relationships).
  2. Core Setup:
    • Install via Composer.
    • Publish configs (--tag=config).
  3. Model Integration:
    • Add use Linkable to target models.
    • Define linkableConfig() with routeName, optionLabel, etc.
  4. UI Integration (if using Nova/Filament):
    • Replace custom fields with Linkable::make().
    • Configure optionsClasses to restrict link types.
  5. Testing:
    • Validate URLs ($model->url()).
    • Test Nova field filtering/searching.
    • Load-test with high-cardinality data.

Operational Impact

Maintenance

  • Pros:
    • Reduced Boilerplate: No need to maintain custom pivot tables or relationship logic.
    • Centralized Configs: Changes to link behavior (e.g., URL format) are in one place (linkableConfig()).
    • Active Development: Package has recent releases (2026-05-11) and CI checks.
  • Cons:
    • AGPL Dependency: Future Laravel updates may require package forks.
    • Configuration Drift: Custom LinkableConfig settings may diverge across models.
    • Debugging: Trait-based logic can obscure stack traces (e.g., "Why is $post->url() returning null?").

Support

  • Strengths:
    • Nova/Filament Fields: Reduces support tickets for "broken link UI" issues.
    • Documentation: README covers core use cases (though sparse on edge cases).
  • Weaknesses:
    • Limited Adoption: No stars/dependents mean community support is nonexistent.
    • Error Handling: Package may lack robust validation (e.g., circular links).
    • Localization: Assumes Laravel’s built-in system; custom setups (e.g., Spatie) require overrides.

Scaling

  • Performance:
    • Nova Field Loads: optionsQuery scans (e.g., published()) could slow down admin panels with large datasets. Mitigation: Add indexes to optionSearch columns (e.g., title, slug).
    • URL Generation: getUrlCallback is called per-model; ensure it’s optimized (e.g., avoid N+1 queries).
    • Pivot Tables: Many-to-many links will create linkable tables. Mitigation: Use database indexes on source_id, target_id.
  • Concurrency:
    • Race Conditions: Concurrent attach()/detach() calls could corrupt pivot tables. Mitigation: Use database transactions.
    • Caching: URLs ($model->url()) are likely cached by Laravel’s route system, but test under load.

Failure Modes

Failure Scenario Impact Mitigation
Misconfigured routeName Broken URLs ($post->url() returns null) Validate routes via Linkable::hasRoute()
optionLabel returns null Nova field shows empty options Default to id or toString() in config
Circular links (A→B→A) Infinite loops in traversal Add validation in linkableConfig
Deleted model referenced Broken links in UI/API Use resolveQuery to filter soft-deleted models
High-cardinality optionsQuery Slow Nova field loading Add indexes to search columns
AGPL license incompatibility Legal blocker for proprietary code Fork and relicense

Ramp-Up

  • Developer Onboarding:
    • Time: 1–2 hours to understand LinkableConfig and trait usage.
    • Key Concepts:
      • routeName/routeParameterName for URL generation.
      • optionLabel/optionSearch for Nova field behavior.
      • resolveQuery for filtering linkable models.
    • Hands-On: Walkthrough of adding use Linkable to a model and testing $model->url().
  • Team Adoption:
    • Pros:
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.
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours