1. Go to this page and download the library: Download jcfrane/laravel-md-blog library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jcfrane / laravel-md-blog example snippets
use JCFrane\MdBlog\Facades\MdBlog;
// All published posts
$posts = MdBlog::all();
// Single post by slug
$post = MdBlog::find('my-first-post');
// Filter by tag
$posts = MdBlog::whereTag('laravel');
// Filter by category
$posts = MdBlog::whereCategory('tutorials');
// Published posts, newest first
$posts = MdBlog::latest();
// Paginated, newest first (page read from the request like Eloquent)
$posts = MdBlog::paginate(9);
// Clear the cache
MdBlog::clearCache();
MdBlog::query()
->whereTag(['sleep', 'focus']) // any of these tags
->whereAllTags(['sleep', 'science']) // every one of these tags
->whereCategory('guides') // string or array
->whereMeta('author', 'JC') // extra front matter; one arg checks the key exists
->whereYear(2026)
->search('white noise') // case-insensitive over title, excerpt, tags, body
->where(fn (Post $post) => $post->readingTime <= 5)
->latest() // or ->oldest(), ->orderBy('title'), ->orderBy(fn ($p) => ..., 'desc')
->skip(10)->take(5)
->get(); // ->first(), ->count(), ->exists()
$post = MdBlog::find($slug);
MdBlog::previous($post); // older post or null
MdBlog::next($post); // newer post or null
MdBlog::related($post); // up to 3 posts sharing tags or category, best match first
MdBlog::related($post, 6);
namespace App\Blog;
use JCFrane\MdBlog\Post;
class CustomPost extends Post
{
public static function make(array $attributes): static
{
// Transform the rendered HTML before readonly properties are set
$attributes['html'] = \Spatie\ShikiPhp\Shiki::highlight($attributes['html']);
return parent::make($attributes);
}
}
use JCFrane\MdBlog\Contracts\EmailRecipient;
use JCFrane\MdBlog\Traits\ReceivesPostMail;
use JCFrane\MdBlog\Post;
class User extends Authenticatable implements EmailRecipient
{
use ReceivesPostMail;
public function shouldReceivePostEmail(Post $post): bool
{
return $this->subscribed_to_newsletter;
}
}