Laravel Paper: Markdown Files as Eloquent Models
Chapters15
An introduction to Larville paper, which lets you treat flat files as eloquent records without a database or migrations. The video teases exploring this approach.
Laravel Paper lets you treat flat Markdown files as Eloquent models, enabling a no-database notes app with instant UI updates and easy switch to a database later.
Summary
Laravel News walks through the Larville Paper package, showing how you can model flat files as Eloquent records without any database setup. The host demonstrates a small notes app with notebooks and notes, all stored as files on disk and accessed through Eloquent-like relationships. The example uses Markdown as the content driver, but mentions other drivers like JSON are available. You’ll see a Notebook model that hasMany Notes and a Note model that belongsTo a Notebook, with content living under content/notebooks and content/notes. The walkthrough emphasizes how changes save instantly and reflect in the UI, illustrating the seamless symmetry with standard Laravel relationships. The presenter also notes that if you later decide to switch to a database, the codebase remains largely intact because the interaction is still via Eloquent. Practical tips include how to perform a title or content search via note queries and how to update a note through a straightforward save call. Overall, the video positions Laravel Paper as a light, version-control-friendly approach for small-scale content, documentation, or lightweight catalogs, while acknowledging it’s best suited for simpler use cases.
Key Takeaways
- Laravel Paper treats flat files as Eloquent records, avoiding migrations and databases while still providing full Eloquent relationships.
- The demo uses a Markdown driver and a content path (content/notebooks and content/notes) to store notebooks and notes on disk.
- Notebook hasMany Notes and Note belongsTo Notebook, mirroring classic Eloquent relationships in a file-based setup.
- Code examples show setting the driver and content path on the models (e.g., Notebook and Note) and performing standard Eloquent operations like save and relationship queries.
- Search capability is demonstrated with a note query that filters by title or content to find matches such as a specific term.
- The package promises easy future switchability to a database without breaking the existing model logic, since interactions are still Eloquent-based.
- Notes updates reflect immediately in the UI, highlighting a snappy, interactive editing experience within the app.
Who Is This For?
Essential viewing for Laravel developers curious about lightweight content management or documentation apps who want to keep data in version-controlled Markdown files and still leverage Eloquent relationships.
Notable Quotes
""Larville paper lets you treat flat files as eloquent records. No database, no migration, just files on your disk.""
—Opening summary of what Larville Paper does and its core appeal.
""We have a full UI set up here. We have all our notes listed. We have different notebooks. We have searching...""
—Demonstrates the UI and core features like listing, notebooks, and search.
""The beauty of this is if you ever do outgrow it and you want to switch to a database you can just easily swap this over and basically everything still works because it's just eloquent.""
—Highlights the portability and future-proofing of the approach.
Questions This Video Answers
- How does Laravel Paper map Markdown files to Eloquent models?
- Can I switch from Markdown-based storage to a database without rewriting controllers in Laravel?
- What are the best use cases for a file-based Laravel app like notebooks and notes?
- What drivers does Laravel Paper support besides Markdown?
- How do you set up content paths and relationships in a Laravel Paper model?
Laravel PaperLarville paperMarkdown driverEloquent modelsNotebook-Note relationshipContent pathDriver: markdownNo database migrationsLaravel News
Full Transcript
Larville paper lets you treat flat files as eloquent records. No database, no migration, just files on your disk. Um, it's pretty neat. And in this video, why don't we dive in and take a look at this package? So, I've had Claude called generate me a sample app. I was like, what would be a good use case here? And I came up with an idea of a little notes application. That way, I could keep up with maybe some notes throughout the day, things like that. you know, I think it needed to be something fairly simple yet complex enough to kind of show you sort of what this package can do.
Um, so we have a full UI set up here. We have um all our notes listed. We have different notebooks. We have searching, so you can search for Yeah, there we go. Let's search for PHP. You can see it there. You can read it on the web, edit, um, pin it, do all kinds of different little things here through the UI. So, I know you're probably curious, you know, how does this work behind the scenes? And why don't we dive in? So, the first thing you'll do is, of course, install the package like you would any other um PHP or composer package.
Once it's installed, you have quite a few new little things. Let's just look at the content. So, we have the what we have here is content. We have notebooks. I have a Laravel and PHP. And then notes. Um just five of them already preceded here. So the notebooks, that's what's going to house the relationship to the notes, you know, that way you can have each note in a different notebook. So you can see here's Laravel, here's a PHP one, and then if I open up one of the notes, you can see it relates back through a notebook slug.
Now to check the setup, let's look at how this is actually done. So we'll go to app models and let's go with notebook first. So, we have the package installed. It's uh Jacob Jorgensson Larville paper paper. And what we do is set our driver. In this case, I'm using markdown. It has a couple different drivers. I think you can use markdown, JSON, maybe another one or two, but for this demo, we're going to just stick with markdown. And then we set our content path. Finally, you'll just uh use the trait or import the trait. go down and you can see we we actually already have a relationship set up and it feels just like Laravel.
It feels if it's pretty nice, right? Uh so this notebook is related to notes. It has many and that's it. Now let's switch over to the actual note. Same thing, you know, we want to use paper. We want to set the driver for markdown content path. This time it's going to be content notes, which are all those guys. And then we set up our relationship which is belongs to paper I mean belongs to notebook. Um the beauty of this is if you ever do sort of outgrow it and you want to switch to a database you can just easily swap this over and basically everything still works because it's just eloquent.
Nothing nothing crazy here. Notebook controller just to kind of give you an idea of how this is set up. Um, if you want to show a notebook, you're just basically doing notebook find. Again, same way, loop over and, you know, sort them. Uh, a little fancier, you can go to notebook controller we have set up and say you want to do a search, you could do, you know, note query, you know, when we're passing a search string, we want to just call where any title or content like like the search string. So, let's go back and just give you an example here.
So we searched for actually we will search for jobs and Q do Q jobs and patients. So if we go down here and make some edits. I am editing this. Hit save. You can see it showed up immediately there. Um and then if we go over here actually I forgot the name of that file. Patients uh cues and jobs. Sorry. You can see I am editing this. It instantly updated. And then the final thing we we'll demonstrate is the um note controller. We'll go down here to the update and again straightforward Laravel. Um we're filling the model with the changes that we're passing over and then we're calling save on it and then redirecting back.
So we did cover it on the website um Lville paper. You can check it out there. Um, we also give you a few different examples and a few of the relationships. Um, installation. Again, it's just a composer require. And that's it. Now you're off to the races. Um, one thing it did say is, you know, what it's useful for and documentation, product cataloges, or smallcale content management where a traditional database might be unnecessary. For me, I think I like the idea of the, you know, the flat files. That way you can put them in version control and you have a sort of a secondary um history on everything.
I think that's kind of cool. But um I think it would work best for the the small stuff. Like I like the documentation, a little notes app, things like that. But uh it's definitely a creative package and a cool use case. So, if you ever do come across a, you know, a thing where you might want to use something like this, be sure and check it
More from Laravel News
Get daily recaps from
Laravel News
AI-powered summaries delivered to your inbox. Save hours every week while staying fully informed.



