PHP code example of lexdubyna / blade

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

    

lexdubyna / blade example snippets


use Lexdubyna\Blade\Blade;

$blade = new Blade('views', 'cache');

echo $blade->make('homepage', ['name' => 'John Doe'])->render();

echo $blade->render('homepage', ['name' => 'John Doe']);

$blade->directive('datetime', function ($expression) {
    return " echo with({$expression})->format('F d, Y g:i a'); 

$blade->compiler()->components([
    'alert'                     => App\View\Components\Alert::class, // <x-alert type="success" message="OK" />
    'components.anonymous.link' => 'link'                            // <x-link />
])

namespace App\View\Components;

use Lexdubyna\Blade\ViewComponent;

class Alert extends ViewComponent
{
    // all the public properties will be exposed inside the template
    public string $type;
    public string $message;

    protected string $template = 'components.alert'; // $template is