I added Smarty 3.1.33 to my project with composer. The basic functionality works fine, but now to my I want to add an object to Smarty. For this I follow the documentation and have this code:
class My_Object {
function meth1($params, &$smarty_obj) {
return 'this is my meth1';
}
}
$myobj = new My_Object;
require_once __DIR__.'/vendor/autoload.php';
$smarty = new Smarty;
$smarty->register_object('foobar',$myobj);
Very basic according to the documentation, but the result is this:
Notice: Undefined property: Smarty_Internal_Undefined::$objMap in /home/svn/test1/trunk/smarty/vendor/smarty/smarty/libs/sysplugins/smarty_internal_extension_handler.php on line 132
Fatal error: Uncaught --> Smarty: undefined extension class 'Smarty_Internal_Method_Register_Object' <-- thrown in /home/svn/test1/trunk/smarty/vendor/smarty/smarty/libs/sysplugins/smarty_internal_undefined.php on line 62
I cannot find anything on the web about this, so am I the only one who ran into this issue? I hope someone here can help me out so I do not have to start debugging Smarty.
Thanks!
Simply include
<path to Smarty>/libs/SmartyBC.class.php
instead of<path to Smarty>/libs/Smarty.class.php
in your project. It represents a backward compatibility wrapper class with the old function names.See Chapter 19. SmartyBC - Backwards Compatibility Wrapper for example.