PHP code example of marko / layout

1. Go to this page and download the library: Download marko/layout 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/ */

    

marko / layout example snippets


use Marko\Layout\Attributes\Component;

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

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();
    }
}

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