PHP code example of lee-to / yii-blade

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

    

lee-to / yii-blade example snippets


return [
    'lee-to/yii-blade' => [
        'paths' => [
            'default' => '@views',
            'admin' => '@views/admin',
        ],
        'cachePath' => 'runtime/cache/blade/views',
        'componentNamespaces' => [
            'App\\View\\Components' => 'x',
        ],
        'anonymousComponentNamespaces' => [
            '@views/components' => 'x',
        ],
        'directives' => [
            // App\Blade\Directives\MyDirective::class,
        ],
    ],
];



namespace App\Blade\Directives;

use Closure;
use Leeto\YiiBlade\DirectiveInterface;
use Leeto\YiiBlade\DirectiveType;

final class DateTimeDirective implements DirectiveInterface
{
    public function getType(): DirectiveType
    {
        return DirectiveType::DEFAULT;
    }

    public function getName(): string
    {
        return 'datetime';
    }

    public function handler(): Closure
    {
        return fn(?string $expression): string => " echo date('Y-m-d H:i:s', $expression); 

'directives' => [
    App\Blade\Directives\DateTimeDirective::class,
],
blade
{{-- views/hello.blade.php --}}
<h1>Hello, {{ $name }}!</h1>

@if($showGreeting)
    <p>Welcome to Yii3 with Blade!</p>
@endif