PHP code example of feather2 / blade

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

    

feather2 / blade example snippets



return [
    'paths' => [],
    'compiled' => '缓存存放路径'
];


return [
    'providers' => [
        //some some some provider
        'Feather2\Blade\ResourceProvider'
    ]
];


define('ROOT', dirname(__DIR__));
define('CACHE_ROOT', ROOT . '/cache');
define('VIEW_ROOT', ROOT . '/view');

esource;

$container = new Container;
$blade = new Blade(VIEW_ROOT, CACHE_ROOT, $container);
$config = $container['config'];
//兼容下独立blade包无法正常读取 view.xx的bug
$config['view'] = [
    'paths' => $blade->viewPaths,
    'compiled' => $blade->cachePath
];
$container['config'] = $config;

(new BladeProvider\ResourceProvider($container))->register();
echo $blade->make($path, array(/*页面数据*/))->render();

function blade_plugin_datetime(){
    return ' echo date("Y-m-d H:i:s");

现在时间: <div id="datetime">@datetime()</div>

└── view
    └── _plugins_
        └── datetime.php