PHP code example of surgiie / blade

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

    

surgiie / blade example snippets




use Surgiie\Blade\Blade;
use Illuminate\Container\Container;
use Surgiie\Blade\Component;

// set a cache directory for compiled cache files, defaults to vendor/surgiie/blade/.cache
Blade::setCachePath("/tmp/.blade");

$blade = new Blade(
    // pass optional container, defaults to: Container::getInstance() or new instance.
    container: new Container,
);

// then render any textual file by path and vars:
$contents = $blade->render("/path/to/file", ['var'=>'example']);

Blade::deleteCacheDirectory();

$blade = new Blade();

$blade->directive('echo', fn ($expression) => " echo {$expression}; 

Blade::components([
    'components.example' => App\Components\Alert::class,
]);


use Surgiie\Blade\Component;

class Alert extends Component;
{
   /** ....*/
}

return Alert::class;
html
<x-alert.php />