PHP code example of lldca / swoft-blade

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

    

lldca / swoft-blade example snippets


'components' => [
    'custom' => [
        'Swoft\\Blade\\'
    ],
],
'blade-view' => [
    'path' => '@root/resources/views', // 默认模板路径
    'compiled' => '@root/runtime/views', // 编译模板缓存路径
    'namespaces' => [ // 视图命名空间
        
    ],
    'assets' => [ // 静态资源读取目录
        
    ],
    'read-assets' => true, // 开启加载静态资源
],


 /**
 * @RequestMapping("index")
 *
 * @return \Psr\Http\Message\ResponseInterface
 */
public function index()
{
    return blade('test::main.index', ['msg' => '测试'])
        ->toResponse()
        ->withAddedHeader('Content-Type', 'charset=utf-8');
}