composer require qq958691165/tp3-lara-blade
共有两种用法: 控制器用法(局部使用)、配置用法(全局使用)
若无"APP_DIR"常量请先定义该常量,值为Runtime的父级目录
use Tp3LaraBlade\Library\BladeView;
class AbstractController extends \Think\Controller {
public function __construct()
{
parent::__construct();
$this->view=BladeView::instance();
}
}
Home/Controller/IndexController.class.php
class IndexController extends AbstractController{
public function index(){
$this->msg='123456';
// $str=$this->fetch();
// dump($str);
$this->display();
}
}
Home/View/default/Index/index.blade.php
@extends('Home::default.Index.layout')
@section('body')
<p>hello {{$msg}}</p>
@endsection
配置config.php(或C函数配置)
return [
//...
'TMPL_ENGINE_TYPE'=>'blade',
'TMPL_TEMPLATE_SUFFIX'=>'.blade.php',
//...
];
或
C('TMPL_ENGINE_TYPE','blade');
C('TMPL_TEMPLATE_SUFFIX','.blade.php');
blade模板语法请参考laravel文档
\Tp3LaraBlade\RegisterContainer::registerNamespace('Admin',APP_DIR.'/Admin/View');