lldca/swoft-blade

v0.1.1 2018-12-22 03:19 UTC

This package is not auto-updated.

Last update: 2024-04-14 03:17:51 UTC


README

Lavarel5.6 blade模板引擎移植

安装

需要把composer源切为https://packagist.laravel-china.org,或国外源。

运行: composer require lldca/swoft-blade

如果安装后使用有问题,请运行 composer update 更新下最新的swoft组件。

Swoft配置

在配置文件 config/properties/app.php 结尾处添加如下配置:

'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');
}