In this episode, we dive into working with the Laravel Sheets package, which is a really neat way of storing and reading static content (like Markdown files) in your project — perfect for handling blog posts without using a database.
Here's what we cover:
- We set up the Sheets package from scratch, install it, and run through the initial config you need to get started.
- You'll see how to define a collection (in our case, for posts), point it at a filesystem disk, and then create a simple Post class that represents each Markdown document as if it were a Laravel model (but no database involved!).
- We go over creating a custom disk in the Laravel filesystem, setting its location in the storage directory to keep raw Markdown files private (not exposed to the public directory).
- Then we wire everything up: the config, the post model, and the directory. Once that's done, we use the Sheets facade to fetch all posts from the Markdown files and dump them out in a collection (just like you'd do with Eloquent models!).
- Finally, we create our first Markdown post file, walk through file naming conventions (using dates and slugs), and see the posts showing up in the collection, complete with handy attributes like the
date
, slug
, and contents
.
At the end of the episode, you’ll have the core setup to create blog posts in Markdown, read them in your Laravel app, and get ready to start listing and styling them on your index page in the next episode.