- Can I use Laravel Paper for a production blog with 5,000+ posts?
- Laravel Paper works for production, but performance may degrade with large datasets due to file I/O. For 5,000+ posts, consider caching results (e.g., Redis) or splitting content into subdirectories by year/month. Test read/write speeds under load before scaling.
- How do I migrate from SQL to flat files with Laravel Paper?
- Export your SQL data to JSON/Markdown files using Laravel’s query builder or a custom script, then update your models to use the `#[Driver]` and `#[ContentPath]` attributes. Test thoroughly, as relationships and constraints won’t auto-migrate. Use a staging environment for validation.
- Does Laravel Paper support relationships between models (e.g., Post hasMany Comments)?
- Yes, but relationships require both models to use Laravel Paper. Define relationships normally (e.g., `hasMany(Comment::class)`), but ensure the foreign key (e.g., `post_id`) maps to the slug of the parent file. Complex relationships may need custom logic for file-based lookups.
- Will Laravel Paper work with Laravel Vapor or multi-server deployments?
- Laravel Paper relies on shared filesystem access (e.g., S3, EFS). For multi-server setups, ensure all instances use the same storage backend and handle file locking manually if concurrent writes are possible. Avoid local filesystems in distributed environments.
- How do I handle concurrent edits to the same Markdown/JSON file?
- Laravel Paper lacks built-in file locking, so concurrent edits risk overwriting changes. Mitigate this by implementing optimistic locking (e.g., a `last_updated_at` timestamp) or using a queue system to serialize writes. For critical data, consider SQL or a dedicated CMS.
- Can I use Laravel Paper with Laravel Scout for full-text search?
- No, but you can integrate external search tools like Algolia or Meilisearch by indexing the file contents separately. Laravel Paper provides the raw data; you’d need to sync changes to your search provider via model observers or events.
- What’s the best way to back up content stored in flat files?
- Back up the entire content directory (e.g., `content/posts`) using your existing filesystem backup strategy. For cloud storage (S3), use versioning or lifecycle policies. Test restores by copying files to a staging environment and verifying Eloquent queries work as expected.
- Does Laravel Paper support soft deletes or model events like `saved` or `deleted`?
- Yes, Laravel Paper supports Eloquent events (e.g., `saved`, `deleted`) and soft deletes via the `use SoftDeletes` trait. Soft deletes work by adding a `deleted_at` field to your Markdown/JSON files. Events trigger normally, but file operations may need error handling for edge cases.
- How do I secure sensitive data stored in JSON/Markdown files?
- Avoid storing sensitive data in flat files entirely. If you must, restrict file permissions (e.g., `storage:link --relative` with `chmod 600`) and encrypt files at rest using Laravel’s encryption services. Never expose these files publicly via web routes.
- What alternatives exist if I need flat-file storage but Laravel Paper lacks a feature?
- Alternatives include Spatie’s `laravel-medialibrary` (for file-based assets), `spatie/array-to-xml` (for XML support), or custom drivers using Laravel’s `DatabaseManager`. For CMS-like workflows, consider Statamic or October CMS. If you need SQL-like features, evaluate SQLite or a lightweight database like Redis.