PHPackages                             snellingio/folio-markdown - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. snellingio/folio-markdown

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

snellingio/folio-markdown
=========================

Add markdown support to Laravel Folio routing

v1.0.0-beta.1(2y ago)91103[1 issues](https://github.com/snellingio/folio-markdown/issues)[2 PRs](https://github.com/snellingio/folio-markdown/pulls)MITPHPPHP ^8.1

Since Aug 9Pushed 2y ago1 watchersCompare

[ Source](https://github.com/snellingio/folio-markdown)[ Packagist](https://packagist.org/packages/snellingio/folio-markdown)[ Docs](https://github.com/snellingio/folio-markdown)[ RSS](/packages/snellingio-folio-markdown/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (24)Versions (4)Used By (0)

Markdown for Laravel Folio
==========================

[](#markdown-for-laravel-folio)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a5f9cd3edd172da47b1ea2faa120773f0a95d38e9a555f001cb0e0cbfa2773e3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736e656c6c696e67696f2f666f6c696f2d6d61726b646f776e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/snellingio/folio-markdown)[![GitHub Tests Action Status](https://camo.githubusercontent.com/424ed4fba9c70d7a31afa49c8d2d668a71815e0968661739c4144db6676e1ac8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736e656c6c696e67696f2f666f6c696f2d6d61726b646f776e2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/snellingio/folio-markdown/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/fcf31642ab7a9c02e15c232faa36c6d3da2a08dda260f1898f386d95f08a0233/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736e656c6c696e67696f2f666f6c696f2d6d61726b646f776e2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/snellingio/folio-markdown/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/8a4add78117d3deb0cb814443ba3ffe03b152ff2b7a210c21486cf5d7edc47d8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736e656c6c696e67696f2f666f6c696f2d6d61726b646f776e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/snellingio/folio-markdown)

Folio Markdown is an extension for the Laravel Folio page-based router that enables the creation of routes using `.md`and `.blade.md` files. This simplifies the process of generating routes in Laravel applications.

Overview
--------

[](#overview)

Laravel Folio allows you to generate routes by creating Blade templates in your application's `resources/views/pages`directory. Folio Markdown enhances this functionality by enabling you to create routes using Markdown files in the same directory.

For example, to create a page accessible at the `/greeting` URL, you can create a `greeting.md` file in the `resources/views/pages` directory:

```
---
view: layouts.app
title: Greetings From Space!
---

# Greetings earthlings!

...
```

The YAML front matter is converted into variables for the view template, and the Markdown content is passed to the view template as a `$slot` variable.

Installation Steps
------------------

[](#installation-steps)

Follow these steps to install and setup Folio Markdown:

1. **Install Laravel Folio:** Use Composer to install Laravel Folio into your Laravel application:

```
composer require laravel/folio:^1.0@beta
```

2. **Execute `folio:install`:** Run the `folio:install` Artisan command. This installs Folio's service provider and registers the directory where Folio will look for routes or pages:

```
php artisan folio:install
```

3. **Install the Folio Markdown package:** Install the Folio Markdown package using Composer:

```
composer require snellingio/folio-markdown:^1.0@beta
```

4. **Register Folio Markdown:** In your `App\Providers\FolioServiceProvider` file, call the `register` method using the FolioMarkdown Facade:

```
use Snelling\FolioMarkdown\Facades\FolioMarkdown;

class FolioServiceProvider extends ServiceProvider
{

    /**
     * Bootstrap services.
     */
    public function boot(): void
    {
        // Place your Folio calls before the register method
        Folio::path(resource_path('views/pages'))->middleware([
            '*' => [
                //
            ],
        ]);

        // Register Folio Markdown at the bottom of the boot method
        FolioMarkdown::register();
    }
}
```

With these steps completed, you can now create routes using Markdown files in your Laravel application.

Quick Highlights
----------------

[](#quick-highlights)

Folio Markdown supports a variety of features, including:

- **File Extensions**: Files with a `.md` extension are processed as Markdown files. Files with a `.blade.md` extension are processed as a Blade template and then as Markdown, enabling the use of specific Blade directives within your Markdown files. However, some Blade directives, like `@push` and `@section`, that span across components may not work because each file is rendered separately.
- **View Templates**: To specify a view template, use the `view` key in the front matter of the page. The content of the page is passed as the `$slot` variable to the view template.
- **Handling Soft Deleted Models**: By default, soft deleted models are not retrieved when resolving implicit model bindings. If you want Folio Markdown to also retrieve these models, add the `withTrashed` key to the page's front matter.
- **Middleware**: To apply middleware to a specific page, add the `middleware` key to the page's front matter. Alternatively, to apply middleware to a group of pages, chain the `middleware` method after calling the `Folio::path`method.
- **Front Matter**: You can add any additional front matter to your page to be passed as view data. For instance, you might add a `title` key to the page's front matter, which will be passed as the `$title` variable to the view template.

Please refer to the detailed guide below for a comprehensive understanding of each feature.

### Understanding File Extensions

[](#understanding-file-extensions)

Files that end with `.md` are automatically recognized and processed as Markdown files. If a file ends with `.blade.md`, it will first be processed as a Blade template, then as a Markdown file. This allows you to use specific Blade directives within your Markdown files. However, keep in mind that some Blade directives, like `@push` and `@section`, that are used across components might not work because each file is processed individually.

### Markdown Extensions

[](#markdown-extensions)

Under the hood, Folio Markdown uses the [Spatie Laravel Markdown](https://spatie.be/docs/laravel-markdown/v1/introduction) package.

While Folio Markdown respects the config of the Spatie Laravel Markdown package, currently code highlighting via Shiki is disabled (@TODO: need to create an issue!).

### How to Use View Templates

[](#how-to-use-view-templates)

To use a view template, you need to include the `view` key in the front matter of the page, like this:

```
---
view: app.layouts
---

# Hello World!
```

The content of the page will then be passed to the view template as the `$slot` variable.

### Working with Soft Deleted Models

[](#working-with-soft-deleted-models)

By default, soft deleted models are not included when resolving implicit model bindings. If you want Folio Markdown to also include these models, add the `withTrashed` key to the page's front matter:

```
---
withTrashed: true
---

# Hello Trashed!
```

### Applying Middleware

[](#applying-middleware)

If you want to use middleware for a specific page, include the `middleware` key in the page's front matter:

```
---
middleware: auth
---

# Hello Middleware!
```

If you want to use middleware for a group of pages, you can do so by chaining the `middleware` method after calling the `Folio::path` method.

### Adding More Front Matter

[](#adding-more-front-matter)

You can add any additional front matter to your page. For example, you might want to add a `title` key to the page's front matter:

```
---
view: app.layouts
title: Hello World!
---
```

This will be passed as the `$title` variable to the view template. This applies to all front matter keys.

The Same Folio You Know and Love
--------------------------------

[](#the-same-folio-you-know-and-love)

### Creating Subpages

[](#creating-subpages)

To create a subpage in Folio, you need to make a new directory within an existing one. For example, if you want to create a page that can be accessed via `/user/profile`, you would create a `profile.md` template within the `pages/user`directory like this:

```
# pages/user/profile.md → /user/profile
```

### Setting a Default Page

[](#setting-a-default-page)

Sometimes, you might want to set a specific page as the default for a directory. You can do this by placing an `index.md` or `index.blade.md` template within a Folio directory. Any requests to the root of that directory will then be directed to that page:

```
# pages/index.md → /
# pages/users/index.md → /users
```

### Using URL Segments in Your Page

[](#using-url-segments-in-your-page)

There might be times when you need to use parts of the incoming request's URL in your page. For example, you might need to access the "ID" of a user whose profile is being displayed. To do this, you can include a segment of the page's filename in square brackets:

```
# pages/users/[id].blade.md → /users/1
```

You can then use these captured segments as variables within your `.blade.md` template, or within the parent `view`component:

```

    User {{ $id }}

```

To capture multiple segments, you can prefix the encapsulated segment with three dots `...`:

```
# pages/users/[...ids].blade.md → /users/1/2/3
```

When capturing multiple segments, the captured segments will be injected into the page as an array:

```

    @foreach ($ids as $id)
    User {{ $id }}
    @endforeach

```

### Linking URL Segments to Models

[](#linking-url-segments-to-models)

If a wildcard segment of your page template's filename matches one of your application's Eloquent models, Folio will automatically link it to Laravel's route model binding capabilities and try to inject the resolved model instance into your page:

```
# pages/users/[User].md → /users/1
# pages/users/[User].blade.md → /users/1
```

The captured models can then be accessed as variables within your `.blade.md` template or the parent `view` component. The model's variable name will be converted to "camel case":

```

    User {{ $user->id }}

```

#### Customizing the Model Key

[](#customizing-the-model-key)

If you want to link bound Eloquent models using a column other than `id`, you can specify the column in the page's filename. For example, a page with the filename `[Post:slug].blade.md` will try to link the bound model via the `slug`column instead of the `id` column.

#### Specifying the Model Location

[](#specifying-the-model-location)

By default, Folio will look for your model within your application's `app/Models` directory. However, if needed, you can specify the full model class name in your template's filename:

```
# pages/users/[.App.Models.User].blade.md → /users/1
```

### Writing PHP Code in Your File

[](#writing-php-code-in-your-file)

If you need to write PHP code within your file, you must end it in a `.blade.md`.

You can then use the `@php` Blade directive:

```
@php
    if (! Auth::user()->can('view-posts', $user)) {
        abort(403);
    }

    $posts = $user->posts;
@endphp

@foreach ($posts as $post)

        {{ $post->title }}

@endforeach
```

Please note that in Folio, the `` tags are only for Folio page definition functions such as `middleware`and `withTrashed`, which are not supported by Folio Markdown at this time.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1011d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7a37f810a66179a1246036739392736412ab4530b3c45b5eafc13244a9ec2be0?d=identicon)[snellingio](/maintainers/snellingio)

---

Top Contributors

[![snellingio](https://avatars.githubusercontent.com/u/9887585?v=4)](https://github.com/snellingio "snellingio (19 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

markdownfoliofolio-markdown

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/snellingio-folio-markdown/health.svg)

```
[![Health](https://phpackages.com/badges/snellingio-folio-markdown/health.svg)](https://phpackages.com/packages/snellingio-folio-markdown)
```

###  Alternatives

[laravel/folio

Page based routing for Laravel.

608453.9k27](/packages/laravel-folio)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[laravel-doctrine/orm

An integration library for Laravel and Doctrine ORM

8425.3M87](/packages/laravel-doctrine-orm)[illuminate/queue

The Illuminate Queue package.

20331.4M1.2k](/packages/illuminate-queue)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
