Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Failed opening required 'Smarty_Internal_Config.class.php'

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
mareh
Smarty n00b


Joined: 04 Mar 2012
Posts: 2

PostPosted: Sun Mar 04, 2012 8:02 am    Post subject: Failed opening required 'Smarty_Internal_Config.class.php' Reply with quote

Hello,

I'm trying to upgrade an old app from Smarty 2 to Smarty 3 because PHP is ver. 5.

I get an error of
PHP Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required 'Smarty_Internal_Config.class.php' (include_path='.:/path/to/lib/php') in /path/to/htdocs/samples/MyAuth.php on line 5

At the line 5 of MyAuth.php, $name has the value of "MySmarty" as well as "Smarty_Internal_Config".
Code:

<?php
require_once("Auth/Auth.php");

function __autoload($name){
   require_once($name.".class.php");
}


I simply tried to rewrite like below
Code:

<?php
require_once("Auth/Auth.php");

function __autoload($name){
   // require_once($name.".class.php");
   require_once("MySmarty.class.php");
}


Then I got a different error
Class 'Smarty_Internal_Config' not found in /path/to/Smarty/libs/sysplugins/smarty_internal_data.php on line 279

I found a thread about the same error, and checked both versions and any missing files but versions are matched and there is no missing file.
http://www.smarty.net/forums/viewtopic.php?p=78105

I've also researched about the __autoload function then figured about the following mention in SMARTY_2_BC_NOTES.txt
Quote:
== Autoloader ==
Smarty 3 does register its own autoloader with spl_autoload_register. If your code has an existing __autoload function then this function must be explicitly registered on the __autoload stack.


I tried to follow the stuff above
Code:

<?php
require_once("Auth/Auth.php");

function __autoload_lib($name){
   require_once($name.".class.php");
}

spl_autoload_register('__autoload_lib');


but again I got the same error of Failed opening required 'Smarty_Internal_Config.class.php'

I'm new to PHP and Smarty. Please help and tell me what I'm missing here. Sad
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sun Mar 04, 2012 9:19 am    Post subject: Reply with quote

If there are multiple autoloaders they must be registered and each must only try to include classes it was intended for (existing in the scope of the autoloader).

Example in your case
Code:
function __autoload_lib($name){
  if (file_exists($name.".class.php")) require_once($name.".class.php");
}
Back to top
View user's profile Send private message
mareh
Smarty n00b


Joined: 04 Mar 2012
Posts: 2

PostPosted: Mon Mar 05, 2012 8:17 pm    Post subject: Reply with quote

Hi U.Tews,

Thank you for you reply. I've tried your codes but there is another error says
Class "MySmarty" not found in MyAuth.php

I think the __autoload() can only load one class at a time?! Could you please tell me how to load all classes in an array?

Please help me..
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3 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