Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Smarty exception: "Please use parent::__construct() to call parent constructor"

I'm following a tutorial and after setting everything up I'm getting:

Fatal error: Uncaught exception 'SmartyException' with message 'Please use parent::__construct() to call parent constuctor'

This is my config file:

<?php
// SITE_ROOT contains the full path to the tshirtshop folder
define('SITE_ROOT', dirname(dirname(__FILE__)));
// Application directories
define('PRESENTATION_DIR', SITE_ROOT . '/presentation/');
define('BUSINESS_DIR', SITE_ROOT . '/business/');
// Settings needed to configure the Smarty template engine
define('SMARTY_DIR', SITE_ROOT . '/libs/smarty/');
define('TEMPLATE_DIR', PRESENTATION_DIR . 'templates');
define('COMPILE_DIR', PRESENTATION_DIR . 'templates_c');
define('CONFIG_DIR', SITE_ROOT . '/include/configs');
?>

My directory structure is:

mydomain.com/test/include
mydomain.com/test/libs
mydomain.com/test/presentation

How can I fix this error?

like image 765
Bob Avatar asked Feb 14 '26 02:02

Bob


1 Answers

This means there is a class extending the Smarty class that is using __construct method that needs to contain something like:

public function __construct() {
    parent::__construct();
}

this will call the smarty construct method which looks something like this:

public function __construct()
{ 
        // selfpointer need by some other class methods
        $this->smarty = $this;
    if (is_callable('mb_internal_encoding')) {
        mb_internal_encoding(SMARTY_RESOURCE_CHAR_SET);
    } 
    $this->start_time = microtime(true); 
    // set default dirs
    $this->template_dir = array('.' . DS . 'templates' . DS);
    $this->compile_dir = '.' . DS . 'templates_c' . DS;
    $this->plugins_dir = array(SMARTY_PLUGINS_DIR);
    $this->cache_dir = '.' . DS . 'cache' . DS;
    $this->config_dir = '.' . DS . 'configs' . DS;
    $this->debug_tpl = SMARTY_DIR . 'debug.tpl';
    if (isset($_SERVER['SCRIPT_NAME'])) {
        $this->assignGlobal('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']);
    } 
} 
like image 56
Shay Anderson Avatar answered Feb 16 '26 17:02

Shay Anderson