Edited at

How to use Smarty with CakePHP 3.0

More than 3 years have passed since last update.

This is a tutorial for installing Smarty to CakePHP 3.0.

In :日本語

In :español


Steps


1. Download the SmartyView

from here: https://github.com/yukikikuchi/cakephp3-smartyview

Save SmartyView as app/src/View/SmartyView.php


2. Download the smarty template engine

http://smarty.php.net/download.php

Extract it to app/vendor/smarty


3. Include in your controller

(in AppController.php to do it app-wide)


AppController.php


class AppController extends Controller {
public $viewClass = 'App\View\SmartyView';
}



4. Create the layout file

Create a file app/src/Template/Layout/default.tpl and paste in that file:


default.tpl


{$this->fetch('content')}