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

Manage “linkable” Eloquent models in Laravel: define per-model link configuration (URL callback or route), labels/groups/search, and query customization. Includes a Linkable Nova field plus publishable config and language files.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Strengths:

    • Eloquent-Centric: Aligns perfectly with Laravel’s ORM, leveraging Eloquent models and relationships without requiring additional database tables (beyond what’s already in use). This reduces schema complexity and avoids the overhead of custom pivot tables for linking.
    • Trait-Based Design: The Linkable trait enables composition over inheritance, allowing selective adoption across models (e.g., only Post, Product, or User models) without forcing a monolithic architecture.
    • Query Flexibility: Supports customizable queries for linking (e.g., optionsQuery, resolveQuery), enabling optimization for specific use cases (e.g., filtering by published status or locale).
    • URL Generation: Centralizes URL logic, ensuring consistency across frontend, API, and admin panels. The getUrlCallback and routeName/routeParameterName options accommodate both dynamic and static routing needs.
    • Preview Support: Built-in previewUrl() and previewTokenField handle preview modes (e.g., for draft content), which is critical for CMS-like applications.
  • Gaps:

    • No Native Graph Traversal: While it handles direct links (e.g., Post → Post), it lacks built-in support for multi-hop queries (e.g., "find all posts linked from a user’s posts"). This may require custom query scopes or a separate graph library for complex traversals.
    • Limited Validation: Basic validation (e.g., preventing circular links) is not included out of the box. Teams will need to implement this manually or extend the trait.
    • Admin Panel Dependency: The Nova/Filament fields are a bonus, not a core feature. Teams not using these admin tools will miss out on the UI integration benefits.

Integration Feasibility

  • Laravel 10+ and PHP 8.2+: The package’s requirements align with modern Laravel stacks, reducing compatibility risks. However, teams using older versions (e.g., Laravel 9) will need to assess upgrade paths.
  • Database Agnostic: Works with any database supported by Eloquent (MySQL, PostgreSQL, SQLite), but performance characteristics (e.g., indexing for optionSearch) should be tested.
  • Service Provider Hooks: The package provides clear extension points (e.g., setRouteCallback, setHasRouteCallback) for customizing URL generation, which is useful for teams using localization packages (e.g., Spatie’s Laravel Translatable or Laravel Localization).
  • Configuration Override: The vendor:publish commands allow teams to customize behavior (e.g., autoload_models_in, linkable_routes) without modifying the package’s core code.

Technical Risk

  • Low Risk:
    • Mature Eloquent Integration: The package leverages well-established Laravel patterns (traits, service providers, facades), reducing the chance of breaking changes.
    • Clear Documentation: The README provides step-by-step guidance for installation, configuration, and usage, with examples for Nova and Filament.
    • Test Coverage: The presence of a test suite (albeit with no public test reports) suggests attention to quality, though teams should run composer run test to validate edge cases.
  • Moderate Risk:
    • AGPL-3.0 License: Requires compliance with the AGPL license or a fork/relicense. Teams using proprietary software or closed-source components should evaluate this risk.
    • Limited Adoption: With 0 stars and dependents, the package’s long-term viability is unproven. However, the Novius team (known for Laravel packages like laravel-nova) adds credibility.
    • Performance at Scale: Heavy use of Linkable fields in Nova/Filament could impact admin panel performance. Teams should benchmark with large datasets (e.g., 10K+ linked models).
  • High Risk:
    • No Official Support: Without a public support channel (e.g., Slack, GitHub Discussions), troubleshooting may rely on GitHub issues or community help.
    • Future-Proofing: The package’s roadmap is unclear. Teams should plan for potential forks or maintenance handoffs if Novius discontinues it.

Key Questions

  1. Use Case Alignment:
    • Does our application require dynamic, queryable links between models (e.g., "find all posts linked from a category")? If not, the package may offer limited value.
    • Are we using Laravel Nova or Filament? If not, the admin panel integration is irrelevant.
  2. Performance:
    • How will the package handle large-scale linking (e.g., 100K+ models)? Are there plans to optimize queries or add caching?
    • Will the optionSearch feature impact database performance for models with many linked records?
  3. Customization:
    • Can we extend the trait to add validation rules (e.g., prevent circular links, enforce access control) without forking?
    • How difficult would it be to integrate with third-party packages (e.g., Spatie’s Media Library, Backpack for Nova)?
  4. License:
    • Does the AGPL-3.0 license conflict with our project’s licensing? If so, are we prepared to fork and relicense?
  5. Maintenance:
    • What is the long-term support plan for the package? Is Novius committed to maintaining it, or is it a one-time release?
    • How will we handle breaking changes in future Laravel versions (e.g., if Laravel 11 drops PHP 8.2 support)?

Integration Approach

Stack Fit

  • Laravel Ecosystem:

    • Core Laravel: The package is designed for Laravel 10+, leveraging Eloquent, routing, and service providers. Integration is seamless for teams already using these components.
    • Nova/Filament: The Linkable Nova field and Filament component are optional but valuable for teams using these admin tools. They reduce the need for custom field development.
    • Localization Packages: The getUrlCallback and locale support integrate well with localization libraries (e.g., Spatie’s Laravel Translatable, Laravel Localization). Teams using these will appreciate the built-in locale handling.
    • APIs: The package’s url() and previewUrl() methods simplify API responses by providing standardized link generation.
  • Non-Laravel Components:

    • Frontend Frameworks: The package generates URLs for frontend use, but teams will need to ensure their frontend (e.g., React, Vue, Alpine.js) consumes these links correctly. No direct integration is provided.
    • Search Engines: While the package enables linking, teams will need to integrate with search tools (e.g., Algolia, Meilisearch) separately to index linked relationships.
    • Graph Databases: For advanced traversal (e.g., "find all posts linked within 2 hops"), teams may need to supplement with a graph database (e.g., Neo4j) or custom query logic.

Migration Path

  1. Assessment Phase:

    • Audit existing linking mechanisms (e.g., custom pivot tables, middleware, or manual URL generation).
    • Identify models that would benefit most from Linkable (e.g., Post, Product, User).
    • Evaluate whether current URL generation logic can be replaced by the package’s getUrlCallback.
  2. Pilot Phase:

    • Start with one model (e.g., Post) to test the trait, Nova/Filament field, and URL generation.
    • Implement a custom query scope (e.g., linkedTo(), linkedFrom()) to validate traversal capabilities.
    • Benchmark performance with a subset of data (e.g., 1K linked records).
  3. Integration Phase:

    • Step 1: Add the Trait
      use Novius\LaravelLinkable\Traits\Linkable;
      
      class Post extends Model {
          use Linkable;
          // ...
      }
      
    • Step 2: Configure linkableConfig() Define routeName, optionLabel, optionGroup, and any custom queries (e.g., optionsQuery to filter by published).
    • Step 3: Update Routes Ensure routes (e.g., post_route) are defined to support the routeName/routeParameterName configuration.
    • Step 4: Nova/Filament Integration (Optional) Replace custom Nova fields with Linkable::make() or Filament’s Linkable component.
    • Step 5: Update Frontend/API Replace hardcoded URLs with $model->url() or $model->previewUrl() where applicable.
  4. Validation Phase:

    • Test URL generation across locales, preview modes, and edge cases (e.g., missing routes).
    • Verify Nova/Filament fields render correctly and handle selections/deslections as expected.
    • Confirm query traversal works (e.g., Post::linkedTo($category) returns the correct results).

Compatibility

  • Laravel Versions: Tested with Laravel 10+. Teams using Laravel 9 or below will need to assess compatibility or upgrade.
  • PHP Versions: Requires PHP 8.2+. Teams on
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.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle