- What is amarenkov/laravel-mutable-content used for?
- It lets Laravel developers attach user-defined, typed JSON fields to Eloquent models without creating a migration for every new field. It also supports lists of values and a trigger-based change log on PostgreSQL and MariaDB. It is aimed at CMS-style editable content and similar features that need flexible model attributes managed through a simple API.
- How do I install laravel-mutable-content in a Laravel app?
- Install it with Composer, then register the package service provider if your Laravel version does not auto-discover it. Publish the package configuration and migrations, run the migrations, and configure the models or content records you want to make mutable. Check the README for the exact publish tags and provider class.
- Do I need a new database migration every time I add a field?
- No. The package stores user-defined fields as typed JSON content records, so you can add or edit fields through the package API rather than altering table schemas. You still need the package's own migrations for its storage and change-log tables. This is the main reason to use it for CMS-style content instead of adding JSON columns manually.
- Which databases does the change log support?
- The trigger-based change log is described for PostgreSQL and MariaDB. If you need the change log on another database, verify support in the package documentation or source before relying on it. The mutable content fields themselves are Eloquent-backed, but the trigger behavior is database-specific.
- Which Laravel and PHP versions are compatible?
- The package is Laravel-native, but the provided excerpt does not list exact Laravel and PHP constraints. Check composer.json in the repository for the supported version ranges before installing. Because the release line is pre-1.0, pin a tested version and review changelogs for breaking changes.
- How does the trigger-based change log work?
- On PostgreSQL and MariaDB, database triggers record changes to mutable content so you can keep a history without writing custom logging code in every model. The package exposes the change log through its API, and you should validate the output format and retention behavior for your use case. Trigger-based logging also means database-level setup and migration review matter.
- Can I store lists of values, not just single fields?
- Yes. The package supports lists of values as part of its mutable content model, alongside typed JSON fields. That makes it useful for options, tags, or other repeatable values attached to an Eloquent model. Manage them through the package API and test validation for the types you allow.
- Is laravel-mutable-content suitable for production use?
- It can be suitable for Laravel apps that need flexible content fields, but it is pre-1.0, so treat upgrades carefully and pin a tested version. The change log adds write and storage overhead, so plan indexing, retention, and monitoring before high-volume use. Validate behavior in staging with representative models and database versions.
- How is this different from adding JSON columns or using a CMS package?
- Adding JSON columns manually still requires schema changes and custom validation for each field, while this package provides typed user-defined fields and lists through a Laravel API. It is lighter than a full CMS and focuses on mutable content attached to existing Eloquent models. The built-in change log is the main extra capability versus a simple JSON column.
- How should I test and maintain an integration?
- Start in a development branch by installing the package, publishing its migrations, and attaching content to a representative model. Write integration tests around creating, updating, listing, and reading change-log entries, then compare behavior against your supported PostgreSQL or MariaDB version. For maintenance, pin the package version, watch releases and changelogs, and re-test after upgrades because the project is pre-1.0.