snicco/blade-bundle

v2.0.0-beta.9 2024-09-07 14:27 UTC

README

codecov Psalm Type-Coverage Psalm level PhpMetrics - Static Analysis PHP-Versions

This WordPress bundle configures the standalone snicco/blade-bridge library for usage in applications based on snicco/kernel.

Installation

composer install snicco/blade-bundle

Configuration

This bundle has no configuration options currently.

Usage

Add the TemplatingBundle and the BladeBundle to your bundles.php config file.

<?php
// /path/to/configuration/bundles.php

use Snicco\Bundle\Blade\BladeBundle;
use Snicco\Bundle\Templating\TemplatingBundle;

return [
    
    'bundles' => [
        Snicco\Component\Kernel\ValueObject\Environment::ALL => [
            TemplatingBundle::class,
            BladeBundle::class
        ]   
    ]   
];

You can now render .blade.php with the TemplateEngine that is bound in the kernel container.

use Snicco\Component\BetterWPDB\BetterWPDB;
use Snicco\Component\Kernel\Kernel;
use Snicco\Component\Templating\TemplateEngine;

/**
* @var Kernel $kernel
*/
$kernel->boot();

$template_engine = $kernel->container()->make(TemplateEngine::class);

// Assuming you have a welcome.blade.php view

$template_engine->renderView('welcome', ['greet' => 'Calvin']);

The BladeBundle reconfigures a couple of the disabled blade directives:

  • @auth can be used to check if the current WordPress user is logged in.
  • @guest can be used to check if the current WordPress user is logged out.
  • @role can be used to check a role of the current WordPress user, e.g. @role(editor)

Contributing

This repository is a read-only split of the development repo of the Snicco project.

This is how you can contribute.

Reporting issues and sending pull requests

Please report issues in the Snicco monorepo.

Security

If you discover a security vulnerability within BetterWPCache, please follow our disclosure procedure.