Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Smarty and TinyMVC - Error autoloader!

 
Post new topic   Reply to topic    Smarty Forum Index -> Frameworks
View previous topic :: View next topic  
Author Message
Saich
Smarty n00b


Joined: 22 Apr 2014
Posts: 4

PostPosted: Fri May 13, 2016 3:34 pm    Post subject: Smarty and TinyMVC - Error autoloader! Reply with quote

Hello! Before using an older version of Smarty with TinyMVC. There were no problems. But now I tried to install and got the error:

Code:
Warning: Uncaught exception 'LogicException' with message 'Class Smarty_Internal_Data could not be loaded' in /home/stinvest/domains/freebc.ru/public_html/libs/smarty/Smarty.class.php:81 Stack trace: #0 [internal function]: spl_autoload('Smarty_Internal...') #1 /home/stinvest/domains/freebc.ru/public_html/libs/smarty/Smarty.class.php(81): class_exists('Smarty_Internal...', true) #2 /home/stinvest/domains/freebc.ru/public_html/tinymvc/myapp/plugins/tinymvc_library_smarty.php(6): require_once('/home/stinvest/...') #3 /home/stinvest/domains/freebc.ru/public_html/tinymvc/sysfiles/plugins/tinymvc_load.php(112): spl_autoload('TinyMVC_Library...') #4 /home/stinvest/domains/freebc.ru/public_html/tinymvc/myapp/controllers/default.php(16): TinyMVC_Load->library('Smarty', 'smarty') #5 /home/stinvest/domains/freebc.ru/public_html/tinymvc/sysfiles/TinyMVC.php(120): Default_Controller->index() #6 /home/stinvest/domains/freebc.ru/public_html/index.php(38): tmvc->main() #7 {main} thrown in /home/stinvest/domains/freebc.ru/public_html/libs/smarty/Smarty.class.php on line 81

Fatal error: spl_autoload(): Class TinyMVC_Library_Smarty could not be loaded in /home/stinvest/domains/freebc.ru/public_html/tinymvc/sysfiles/plugins/tinymvc_load.php on line 112


How to solve this problem? I connect so as described here:

http://tinymvc.com/documentation/index.php/Documentation:Templates
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1001

PostPosted: Fri May 13, 2016 3:41 pm    Post subject: Re: Smarty and TinyMVC - Error autoloader! Reply with quote

Saich wrote:
Hello! Before using an older version of Smarty with TinyMVC. There were no problems. But now I tried to install and got the error:

Code:
Warning: Uncaught exception 'LogicException' with message...


How to solve this problem? I connect so as described here:

http://tinymvc.com/documentation/index.php/Documentation:Templates

А можно то же самое, но в читаемом виде?
Back to top
View user's profile Send private message
Saich
Smarty n00b


Joined: 22 Apr 2014
Posts: 4

PostPosted: Fri May 13, 2016 9:08 pm    Post subject: Re: Smarty and TinyMVC - Error autoloader! Reply with quote

AnrDaemon wrote:
Saich wrote:
Hello! Before using an older version of Smarty with TinyMVC. There were no problems. But now I tried to install and got the error:

Code:
Warning: Uncaught exception 'LogicException' with message...


How to solve this problem? I connect so as described here:

http://tinymvc.com/documentation/index.php/Documentation:Templates

А можно то же самое, но в читаемом виде?


Smile подключал раньше smarty 3 к TinyMVC, теперь вот ошибка автозагрузчика как я понял. Версия 3.1-DEV подключалась без проблем.
Back to top
View user's profile Send private message
Saich
Smarty n00b


Joined: 22 Apr 2014
Posts: 4

PostPosted: Sat May 14, 2016 8:54 am    Post subject: Reply with quote

Проблема решена. Подключаем не сам смарти, а автозагрузчик Smile
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1001

PostPosted: Sun May 15, 2016 12:51 am    Post subject: Reply with quote

Ну, вообще-то об этом в инструкции написано.
Кстати, в родном автозагрузчике есть баг.
Небольшой, но неприятный.
Он регистрирует свой загрузчик на верх стека.
Back to top
View user's profile Send private message
zimorok
Smarty n00b


Joined: 18 Aug 2016
Posts: 3

PostPosted: Thu Aug 18, 2016 2:54 am    Post subject: Reply with quote

So, is the problem solve?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1001

PostPosted: Thu Aug 18, 2016 2:26 pm    Post subject: Reply with quote

Yes, the problem was the incorrect inclusion.
OP did include Smarty.class.php instead of the autoloader.
Back to top
View user's profile Send private message
zimorok
Smarty n00b


Joined: 18 Aug 2016
Posts: 3

PostPosted: Fri Aug 19, 2016 12:00 pm    Post subject: Reply with quote

How to solve it?

Please help. I still have the error.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1001

PostPosted: Mon Aug 22, 2016 8:36 pm    Post subject: Reply with quote

Include the autoloder, not Smarty itself, or just use Composer.
Back to top
View user's profile Send private message
vengeance
Smarty n00b


Joined: 20 Oct 2016
Posts: 1

PostPosted: Thu Oct 20, 2016 9:45 pm    Post subject: Reply with quote

Ребят помогите, такая же проблема. Что прописать в /tinymvc/myapp/plugins/tinymvc_library_smarty_wrapper.php ?

Делаю все по инструкции http://tinymvc.com/documentation/index.php/Documentation:Templates
но smarty не цепляется к tiny
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1001

PostPosted: Thu Oct 20, 2016 11:06 pm    Post subject: Reply with quote

Надо прочитать топик прежде чем писать в него.
Back to top
View user's profile Send private message
rdg
Smarty n00b


Joined: 11 Jan 2017
Posts: 2

PostPosted: Wed Jan 11, 2017 4:24 pm    Post subject: Reply with quote

Hi Everyone,

I'm having a similar issue. I'm also using TinyMVC with Smarty 3.0.5, I'm looking to upgrade to 3.1.30 for bug/security fixes but I cannot get it to work.

I've updated tinymvc_library_smarty_wrapper.php to use this:

Code:
<?php

// important so the TinyMVC and Smarty autoloaders work together!
define('SMARTY_SPL_AUTOLOAD', 1);

// require the Smarty class
require(TMVC_BASEDIR . '/myclasses/smarty/libs/Autoloader.php');
Smarty_Autoloader::register();
//require(TMVC_BASEDIR . '/myclasses/smarty/libs/Smarty.class.php');

class TinyMVC_Library_Smarty_Wrapper Extends Smarty
{
  function __construct()
  {
    parent::__construct();
    $this->setTemplateDir(TMVC_BASEDIR . '/myapp/smarty/templates/');
    $this->setCompileDir(TMVC_BASEDIR . '/myapp/smarty/templates_c/');
    $this->setConfigDir(TMVC_BASEDIR . '/myapp/smarty/configs/');
    $this->setCacheDir(TMVC_BASEDIR . '/myapp/smarty/cache/');
  }
}


However I get an error when my templates try to call a custom function "property_image":

Code:
Message: Class Smarty_Internal_Compile_Property_Image could not be loaded
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1001

PostPosted: Thu Jan 12, 2017 4:24 am    Post subject: Reply with quote

I would suggest switching to Smarty master and include Smarty bootstrap instead.
https://github.com/smarty-php/smarty/blob/master/libs/bootstrap.php
Back to top
View user's profile Send private message
rdg
Smarty n00b


Joined: 11 Jan 2017
Posts: 2

PostPosted: Wed Jan 18, 2017 9:37 pm    Post subject: Reply with quote

Thank you for your reply! Smarty 3.1.21 was the last version that could be included using the documentation described here:

http://www.tinymvc.com/documentation/index.php/Documentation:Templates

I was able to get Smarty 3.1.30 working by adding this to the bottom of TinyMVC.php

Code:
///// Added For Smarty Autoloader.php Suppport
function __autoload($classname) {
    // other stuff that had been here before
    if (substr($classname, 0, 15) == "Smarty_Internal") {
        $classname = "Smarty/sysplugins/" . strtolower($classname);
        require_once $classname . ".php";
    }
}


I will look into using the Smarty bootstrap method.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Frameworks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP