0
votes

I was reading Beginning PHP and MySQL ecommerce. The author asks to download latest smarty version.When book was published it was smarty 2.x now its 3.x. I copied all the files from code download to my folder. The error i got was

Fatal error: Uncaught exception 'SmartyException' with message 'PHP5 requires you to call __construct() instead of Smarty()'

To correct it i changed my code to

<?php
    // Reference Smarty library
    require_once SMARTY_DIR . 'Smarty.class.php';

    /* Class that extends Smarty, used to process and display Smarty files */
    class Application extends Smarty
    {
       // Class constructor
       public function __construct()
       {
         // Call Smarty's constructor
         parent::__construct();

         // Change the default template directories
         $this->template_dir = TEMPLATE_DIR;
         $this->compile_dir = COMPILE_DIR;
         $this->config_dir = CONFIG_DIR;
      }
    }
 ?>

I've follow the following links Fatal error: Uncaught exception 'SmartyException'

Then I got this error:

ERRNO: 2 TEXT: filemtime(): stat failed for C:\xampp\htdocs\tshirtshop/presentation/templates_c\b34e4db7de306d57170626b504196f0c5fe34fa4.file.store_front.tpl.php LOCATION: C:\xampp\htdocs\tshirtshop\libs\smarty\sysplugins\smarty_resource.php, line 772, at August 22, 2014, 9:59 am Showing backtrace: filemtime("C:\xampp\htdocs\tshirtshop/presentation/templates_c\b34e4db7de30...") line 772, file: C:\xampp\htdocs\tshirtshop\libs\smarty\sysplugins\smarty_resource.php Smarty_Template_Source.getCompiled(Object: Smarty_Internal_Template) # line 699, file: C:\xampp\htdocs\tshirtshop\libs\smarty\sysplugins\smarty_internal_template.php Smarty_Internal_Template.__get("compiled") # line 154, file: C:\xampp\htdocs\tshirtshop\libs\smarty\sysplugins\smarty_internal_templatebase.php Smarty_Internal_TemplateBase.fetch("store_front.tpl", null, null, null, true) # line 394, file: C:\xampp\htdocs\tshirtshop\libs\smarty\sysplugins\smarty_internal_templatebase.php Smarty_Internal_TemplateBase.display("store_front.tpl") # line 16, file: C:\xampp\htdocs\tshirtshop\index.php

1
What have you done in your smarty template ? I don't see any problem with this code (just that you should use setter). - Debflav

1 Answers

0
votes

Your PHP code looks fine.

You should clear your compiled templates directory, check your directory/files permissions and if it doesn't help, in fact you shouldn't care. Those warnings are because of some file system operations optimization.

If you want to turn them off you can use:

$this->muteExpectedErrors();

inside your constructor (probably after calling parent constructor). Documentation on muteExpectedErrors