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 Publishable Laravel Package

novius/laravel-publishable

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • State Management: The package provides a standardized 4-state workflow (draft, published, unpublished, scheduled) with published_first_at for chronological sorting, which is ideal for content-heavy applications (e.g., blogs, marketing sites, news platforms). This reduces custom query logic and ensures consistency across models.
  • Eloquent Integration: Leverages Eloquent macros and traits, making it non-intrusive and easy to adopt incrementally. The publishable() migration macro simplifies schema changes.
  • Query Scoping: Built-in scopes (published(), draft(), scheduled()) reduce boilerplate and improve readability. However, the removal of the global scope (forcing all queries to return only published records) may require adjustments in existing codebases.
  • Extensibility: While the package is opinionated (4 states), it can be extended for custom logic (e.g., adding a "reviewed" state) via trait overrides or middleware.
  • Performance: The published_first_at field enables efficient sorting but requires proper indexing to avoid performance bottlenecks in large datasets.

Integration Feasibility

  • Low Coupling: The package is model-agnostic, allowing adoption on a per-model basis. This minimizes risk during integration.
  • Database Schema: The publishable() macro adds five columns (status, published_at, published_first_at, scheduled_at, unpublished_at), which is minimal compared to custom implementations.
  • Nova Compatibility: While the package mentions laravel-nova-publishable, the core functionality is Nova-independent, making it usable in vanilla Laravel or other frontend frameworks (e.g., Livewire, Inertia).
  • Event-Driven Extensions: The package does not natively support events, but model observers or listeners can be added to trigger actions (e.g., notifications, cache invalidation) during state transitions.
  • Soft Deletes: The package does not conflict with Laravel’s SoftDeletes, but explicit handling is needed to avoid edge cases (e.g., unpublished + deleted records).

Technical Risk

  • State Transition Logic: The package does not enforce business rules (e.g., "only admins can publish"). Custom validation or policies are required, adding complexity.
  • Scheduled Posts: Timezone handling for scheduled_at relies on Laravel’s config('app.timezone'), which may not align with user-specific timezones or global deployments.
  • AGPL License: Proprietary or commercial projects must either relicense the package or fork it, adding legal and maintenance overhead.
  • Limited Adoption: Low GitHub stars (2) and dependents (0) suggest unproven stability in production. Risk of undocumented edge cases (e.g., concurrent state changes, database deadlocks).
  • PHP 8.2+ Requirement: Legacy systems may require runtime updates or polyfills, increasing migration effort.
  • Caching Implications: State changes (e.g., publish/unpublish) may invalidate caches (Redis, Varnish) if not explicitly managed (e.g., via tags:clear or custom cache keys).

Key Questions

  1. State Validation: How will role-based access control (RBAC) be enforced for state transitions (e.g., draft → published)? Will this use Policies, Middleware, or custom validation?
  2. Timezone Handling: How will scheduled_at and published_first_at be managed across multiple timezones (e.g., editors in UTC vs. users in PST)?
  3. Caching Strategy: Will state changes invalidate caches? If so, how will cache tags or invalidation logic be implemented?
  4. Soft Deletes Conflict: How will the package interact with SoftDeletes? Can a record be both unpublished and soft-deleted? What is the intended behavior?
  5. Testing Coverage: Are there pre-built tests for edge cases (e.g., concurrent state changes, database transactions, or race conditions)?
  6. Nova Integration: If using Nova, does the package fully support Nova’s resource tooling (e.g., toolbars, filters, lenses)? Are there known limitations?
  7. Migration Strategy: For existing tables, how will published_first_at and state fields be backfilled without downtime or data corruption?
  8. Performance: What database indexes are recommended for large datasets (e.g., status, published_at, published_first_at)? Are there query optimization considerations?
  9. Custom States: If additional states (e.g., "archived," "translated") are needed, how will the package be extended without breaking compatibility?
  10. Audit Logging: Does the package support tracking state changes (e.g., via spatie/laravel-activitylog)? If not, how will this be implemented?

Integration Approach

Stack Fit

  • Ideal Use Cases:
    • Content Management Systems (CMS): Blogs, news sites, or marketing pages where content has a clear lifecycle (draft → scheduled → published → unpublished).
    • Editorial Workflows: Applications requiring moderation (e.g., user-generated content, partner submissions) or compliance-driven publishing (e.g., GDPR "right to be forgotten").
    • Laravel Nova Projects: If using Nova, the package can standardize publishable behavior across resources, reducing UI/UX fragmentation.
    • Scheduled Content: Applications needing time-based publishing (e.g., product launches, event listings) without complex cron jobs.
  • Less Ideal Use Cases:
    • High-Frequency CRUD Apps: Systems like e-commerce inventory where publish states add unnecessary complexity.
    • Fine-Grained ACLs: Projects requiring role-specific publish permissions (e.g., "Team A can publish, Team B can only draft").
    • Event-Driven Architectures: Applications relying on broadcasting state changes (e.g., WebSockets, queues) may need additional layers.
    • Multi-Tenancy: The package does not natively support tenant-scoped publish states, requiring custom logic.

Migration Path

  1. Assessment Phase:
    • Audit Models: Identify models that require publishable states (e.g., Post, Article, Product).
    • Review Existing Logic: Document current publish/unpublish workflows to assess overlap or redundancy with the package.
    • Stakeholder Alignment: Confirm alignment with product goals (e.g., editorial control, SEO, compliance).
  2. Pilot Implementation:
    • Select a Model: Start with a low-risk model (e.g., Post) to test:
      • Migration (publishable() macro).
      • State transitions (draft → publish → schedule → unpublish).
      • Query performance (e.g., Model::published()->latest()).
    • Implement State Transitions: Create controllers/services to handle transitions (e.g., PostService::publish()).
    • Test Edge Cases: Validate behavior for:
      • Concurrent state changes.
      • Timezone-sensitive scheduled posts.
      • Soft deletes + unpublished states.
  3. Incremental Rollout:
    • Add to Additional Models: Roll out to other models in phases (e.g., Article, PressRelease).
    • Deprecate Custom Logic: Replace ad-hoc publish logic with the trait’s methods.
    • Update Frontend/APIs: Ensure queries/filtering use the package’s scopes (e.g., ?status=published).
  4. Database Migration:
    • New Tables: Use the publishable() macro in migrations.
    • Existing Tables: Create a migration to add:
      $table->string('status')->default('draft'); // draft|published|unpublished|scheduled
      $table->timestamp('published_first_at')->nullable();
      $table->timestamp('published_at')->nullable();
      $table->timestamp('scheduled_at')->nullable();
      $table->timestamp('unpublished_at')->nullable();
      
    • Backfill Data: Write a seeder or script to populate published_first_at (e.g., created_at for existing published records).

Compatibility

  • Laravel Version: Fully compatible with Laravel 10+; no conflicts with modern features (e.g., model observers, events).
  • PHP Version: Requires PHP 8.2+; may need runtime updates for older versions.
  • Database: Works with MySQL, PostgreSQL, SQLite (tested via Laravel’s DB agnosticism).
  • Testing Frameworks: Compatible with Pest/PHPUnit; may need custom assertions for state transitions.
  • Frontend Frameworks: No direct impact on frontend, but APIs must filter by state (e.g., ?status=published).
  • Caching: No built-in caching, but state changes should trigger cache invalidation (e.g., Redis tags, Varnish purges).
  • Nova: While the package mentions laravel-nova-publishable, the core functionality is Nova-independent. Nova integration would require additional
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.
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
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium