marko/layout

Marko Framework Layout - Layout system with components and slots

Maintainers

Package info

github.com/marko-php/marko-layout

pkg:composer/marko/layout

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.3.0 2026-04-14 18:52 UTC

This package is auto-updated.

Last update: 2026-04-15 15:54:37 UTC


README

Composable layout system with slot-based injection---define layouts and components with attributes, not configuration files.

Installation

composer require marko/layout

Quick Example

Define a layout component with named slots:

use Marko\Layout\Attributes\Component;

#[Component(
    template: 'blog::layout/default',
    slots: ['content', 'sidebar'],
)]
class DefaultLayout {}

Point a controller action at that layout:

use Marko\Layout\Attributes\Layout;
use Marko\Routing\Attributes\Get;
use Marko\Routing\Http\Response;

class PostController
{
    #[Get('/posts/{id}')]
    #[Layout(DefaultLayout::class)]
    public function show(int $id): Response
    {
        return new Response();
    }
}

Inject a page component into a slot from any module:

#[Component(
    template: 'blog::post/body',
    handle: 'post_show',
    slot: 'content',
)]
class PostBodyComponent {}

The layout middleware assembles all components targeting the current handle and renders the final page---no wiring required.

Documentation

Full usage, API reference, and examples: marko/layout