PHP code example of zubdev / ci4smarty

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

    

zubdev / ci4smarty example snippets


    $psr4 = [
        'Config'      => APPPATH . 'Config',
        APP_NAMESPACE => APPPATH,
        'Zubdev\Ci4Smarty' => APPPATH . 'Libraries/Ci4Smarty',
    ];

 namespace App\Controllers;

use Zubdev\Ci4Smarty\Smartie;

class Home extends BaseController
{
	public function index() {
	   $smarty = new Smartie();
		
	   return $smarty->view('index');
	}
}

 namespace App\Controllers;

use Zubdev\Ci4Smarty\Smartie;

class Admin extends BaseController
{
	public function index() {
	
	    $smarty = new Smartie();
	    $data = [
	      'name' => 'John Doe',
	    ];
		
	   return $smarty->view('admin/dashboard', $data);
	}
}



namespace App\Controllers;

use CodeIgniter\Controller;
use CodeIgniter\HTTP\CLIRequest;
use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use Zubdev\Ci4Smarty\Smartie;

class BaseController extends Controller
{
   protected $request;
   protected $smarty;
   
   public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
    {
       $this->smarty = new Smartie();
    }
}

 namespace App\Controllers;

class Home extends BaseController
{
	public function index() {
		
	   return $this->smarty->view('index');
	}
}