PHPackages                             asanusi007/ci4-smarty - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. asanusi007/ci4-smarty

ActiveLibrary[Templating &amp; Views](/categories/templating)

asanusi007/ci4-smarty
=====================

Integrate smarty template engine to CodeIgniter 4 with easy way.

v1.0.0(1y ago)031MITPHPPHP &gt;=8.0

Since Dec 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ahmaddzidan/ci4-smarty)[ Packagist](https://packagist.org/packages/asanusi007/ci4-smarty)[ RSS](/packages/asanusi007-ci4-smarty/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Smarty Template Engine for Codeigniter 4
========================================

[](#smarty--template-engine-for-codeigniter-4)

Simple way to integrate Smarty template engine into Codeigniter 4

Installation
------------

[](#installation)

Use the package manager [composer](https://getcomposer.org/) to install Smarty.

```
composer require asanusi007/ci4-smarty
```

Usage
-----

[](#usage)

Open BaseController.php inside app/Controllers/BaseController.php and add this code

```
use Asanusi007\Smarty\Traits\Viewable;

/**
 * Class BaseController
 *
 * BaseController provides a convenient place for loading components
 * and performing functions that are needed by all your controllers.
 * Extend this class in any new controllers:
 *     class Home extends BaseController
 *
 * For security be sure to declare any new methods as protected or private.
 */
abstract class BaseController extends Controller
{
    use Viewable;

....

}
```

And then, you can use it like this:

```
class Home extends BaseController
{
    public function index()
    {
        $data['title'] = 'Home';
        return $this->parse('home', $data);
    }
}
```

Configuration
-------------

[](#configuration)

You can change the default configuration by copy a file named `smarty.php` in the `Src/Config/` folder to `app/Config/Smarty.php`, then you can change the configuration as you want.

```
